Session Variables in Opencart

user984689 picture user984689 · Dec 12, 2011 · Viewed 36.3k times · Source

Can someone explain where session variables are held?

I have added some session variables in header.php in the controller, for example:

$this->session->data['day']=date("d",strtotime($row['startdate']));

This works when loading the site, and when I click on a product, all the variables are gone, except for the [language], [currency] and [cart] which are set by Opencart.

I guess there is another file or controller file where I set the variables, or where [language], [currency] and [cart] are set but I cannot find it.

Thanks in advance.

Answer

Jay Gilford picture Jay Gilford · Dec 12, 2011

Session values are not set in a file. If you want to set a session variable, use

$this->session->data['variable_name_here'] = 'data value here';

and to retrieve the value you just access

$this->session->data['variable_name_here']

For example, to echo it use

echo $this->session->data['variable_name_here'];