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

Session persistence & id calls

posted by sbisbee 9 years ago

Greetings,

Please assume all functions calls are fSession::

Here is the session code that I was using during a user's login, where I allow them to persist their session ("remember me"):

if($rememberMe)
{
  fSession::enablePersistence(); 
  fSession::setLength("30 minutes", "1 month");
}
else
  fSession::setLength("30 minutes");

fSession::set("uid", $user->_id);
fSession::regenerateID();

When $rememberMe was true, the session was not being persisted - it was still set to expire at the end of the session (30min).

Here is the working code that I'm now using:

fSession::setLength("30 minutes", "1 month");
fSession::set("uid", $user->_id);

if($rememberMe)
  fSession::enablePersistence();
else
  fSession::regenerateID();

I assume that the issue was caused by enablePersistence() also calling regenerateID(), but I could be wrong. Either way, the code works now.

I'm wondering whether this is expected behavior. If it is, then could we please add a note to the fSession page about order mattering? If not, then I'll open a ticket.

Cheers,

Sam Bisbee

I believe the issue was that fSession::enablePersistence() was called before fSession::setLength(). There is some code that is supposed to catch that by looking to see if a persistent length had been set yet. I do need to add a call to fSession::open() to enablePersistence(), and that will catch that you are trying to set the length after the session has been opened. I'll also make sure to explicitly mention in the fSession documentation that fSession::setLength() should be called before enabling persistence.

Thanks for reporting this!

posted by wbond 9 years ago

As of r836, the first series of method calls will result in an fProgrammerException explaining that all of the configuration methods such as fSession::setLength(), fSession::setPath() and fSession::ignoreSubdomain() must be called before fSession::enablePersistence(), among other methods.

posted by wbond 9 years ago

Awesome, thanks. :-)

posted by sbisbee 9 years ago