Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Quick question - does session length start on every refresh, or first visit?

posted by rirez 8 years ago

Just sanity checking my code here - if I set fSession::setLength('1 day'), which of these apply?

A) User opens page every hour, session expires after 24 hours since their first visit
B) User opens page, lets it sit in the browser without refreshing for 24 hours, and upon next refresh it logs out
C) User opens page every hour, never gets logged out

I'm guessing it's C - does this mean setLength is really only for conditions where we need sessions to end prematurely if the user stays idle for too long? Is there any drawback to just setting it for '1 day' if I don't want users to log out because of being idle, and want to wait until they close the tab/browser? Does this mean it will wait 1 day before garbage-collecting the session?

Thanks!

C will occur, and it is due to how PHP session lengths work. The session length is really just the minimum age of the session files before they get garbage collected. This means that at any given point you will have 24 hours worth of session files in your session directory. Depending on the number of visitors you get, this could be a very large number.

posted by wbond 8 years ago

Thanks - that answers my question perfectly. I was wondering if flourish re-engineered the session system in some way that changed how it works. This probably means I'll settle with a shorter length of 1 hour or so.

posted by rirez 8 years ago