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 question

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

In one of my previous forum posts Derek suggested that I use the $SESS global to store my settings.

The question I have is when the extension settings are updated how can I clear the $SESS variable?

Heres what I have so far when accessing the settings from the plugin:

if ( ! isset($SESS->cache['lg_better_meta']['settings']))
    {
      $query = $DB->query("SELECT settings FROM exp_extensions WHERE class = 'lg_better_meta' LIMIT 1");

      if ($query->num_rows > 0)
      {
        foreach ($query->result as $row)
        {
          $SESS->cache['lg_better_meta']['settings'] = $row;
        }
      }    
    }
    $settings = unserialize($SESS->cache['lg_better_meta']['settings']);
       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

The session cache lives only for the runtime of each request. Why would you want to kill those settings in that timeframe?

If you are completely sure you want to kill them, use unset().

e.g.,

unset($SESS->cache['lg_better_meta']['settings']);

But watch your queries take a hike if the extension is being called more than once 😊

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

OK cool… I didn’t know if the session length was the runtime or for a longer amount of time. Using the $SESS object will work well if my plugin/extension is used incorrectly. Thanks

       
Paul Burdick's avatar
Paul Burdick
480 posts
17 years ago
Paul Burdick's avatar Paul Burdick

The $SESS->cache is only for the current loaded page and is not persistent across page loads. That functionality is going to likely be in 2.0 though as there are a number of good uses for it.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham
The $SESS->cache is only for the current loaded page and is not persistent across page loads. That functionality is going to likely be in 2.0 though as there are a number of good uses for it.

Thanks Paul… So we should be expecting a 2.0 release soon 😉

       
Paul Burdick's avatar
Paul Burdick
480 posts
17 years ago
Paul Burdick's avatar Paul Burdick

I am thinking of banning anyone who asks that from being able to download 2.0 when it comes out.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Yep from now on I agree… The old its ready when its ready is nearly always the best direction to take on software releases

       

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.