Session Variables Plugin

Installation

Download and unzip the Session Variables plugin, then follow the simple steps below:

ExpressionEngine 2.x:

  1. Open the session_variables_2_0 folder
  2. Upload the system/expressionengine/third_party/session_variables folder

ExpressionEngine 1.x:

  1. Open the session_variables_1_6 folder
  2. Upload pi.session_variables.php to the system/plugins folder

Updating

Download and unzip the latest version of the Session Variables plugin, then follow the steps below:

ExpressionEngine 2.x:

  1. Overwrite the system/expressionengine/third_party/session_variables folder

ExpressionEngine 1.x:

  1. Overwrite system/plugins/pi.session_variables.php

Template Tags

{exp:session_variables:set name="variable_name" value="variable_value"}
Sets the variable variable_name to variable_value.
The name and value parameters are both required.
POSTED_VALUE is a constant that specifies the value of the posted variable with the specified name.
// setting the language variable to french			
{exp:session_variables:set name="language" value="french"}
// setting the language variable to the second segment			
{exp:session_variables:set name="language" value="{segment_2}"}
// setting the language variable to the posted value			
{exp:session_variables:set name="language" value="POSTED_VALUE"}
{exp:session_variables:get name="variable_name"}
Outputs the value of the variable variable_name.
The name parameter is required.
// getting the language variable
You are currently viewing this page in {exp:session_variables:get name="language"}
{exp:session_variables:delete name="variable_name"}
Deletes the variable variable_name.
The name parameter is required.
// deleting the language variable			
{exp:session_variables:delete name="language"}

Session Lifetime

The lifetime of the session is set in the php.ini file (session.gc_maxlifetime) and is 1440 seconds by default. It can be changed using the ini_set function, however it can be reset in unpredictable ways. This article explains how and why.