[TYPO3-dev] Typo3 Non-User Sessions

Frank Weindel fjw24 at drexel.edu
Fri Dec 12 22:43:52 CET 2008


Francois Suter wrote:
> Hi,
> 
>> I was wondering if there is a Typo3 way to save and retrieve sessions 
>> for a non-logged in user, or should I just use PHP $_SESSSION for this?
> 
> Yes, there is :-)
> 
> The way to store in session is:
> 
> $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $stuff);
> 
> The first parameter indicates whether the stuff is to be stored in the 
> transient part of the session, i.e. the part that's not saved. If you 
> set the parameter to 'user' instead, the stuff will be saved to the 
> corresponding fe_user record when the page is more or less finished 
> rendering.
> 
> The second parameter is the key used to store and retrieve your stuff. 
> Finally, the third parameter is the structure you want to store. It can 
> be any type of PHP data.
> 
> To get the stuff back from the session:
> 
> $GLOBALS['TSFE']->fe_user->getKey('ses', $key);
> 
> HTH
> 
Thanks!

Frank




More information about the TYPO3-dev mailing list