We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

$SESS class variables reset after each page render?

Development and Programming

radar77's avatar
radar77
28 posts
17 years ago
radar77's avatar radar77

Hello,

I am building a plugin which attempts to set a custom $SESS class variable which needs to be stored and reused within multiple template groups in the EE site. My question is: Is a $SESS->cache variable reset after each page renders?

What I want to do is check if the $SESS variable is already set, and if not, set it for reuse.

if (!isset($SESS->cache['custom']['variable']))
{
    $SESS->cache['custom']['variable'] = $IN->GBL('ID');

} else {
    
    $SESS->cache['custom']['variable'] = "value";
    
}

This code works, but it doesn’t seem to retain the $SESS variable. Is a COOKIE a better approach in a case like this?

Cheers

Moved by Moderator

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Yes, the ExpressionEngine Session class does not persist across page loads. Persistent session data should be stored as a cookie or written to the database, depending on your needs and the sensitivity of the data.

       
radar77's avatar
radar77
28 posts
17 years ago
radar77's avatar radar77

Thanks Derek, that clears things up for me.

Cheers!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.