Jump to content

How to store a var in the SESSION?


JasonWang

Recommended Posts

I saw some topics in this forum. It's said Prestashop 1.5 doesnt use $_SESSION.

They recommend to use 

$cookie->myvar = myvalue 

to store var.

 

I tried, but it is stored in the cookie, and value cannot be array, but only string.

Meanwhile, I want the var expires when the session is over.  But according to the method above, when I close brower, open it again, the var is still there.

 

So, how does Prestashop1.5 simulate the SESSION?

Any help would be very appreciated.

Link to comment
Share on other sites

Hi Jason,

Code in 1.5 impies that it DOES use $_SESSION, or at least has knowledge of sessions:

 

for example in:

<your admin folder>/ajaxfilemanager/inc/config.php

 

the code to start a session is found:

if(!isset($_SESSION))
{
  session_start();
}
 
 
and in 
 
<your admin folder>/ajaxfilemanager/ajax_login.php:
if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] === false) {
	
	if(isset($_POST['username']))
	{
		if($auth->login())
		{
			header('Location: ' . appendQueryString(CONFIG_URL_HOME, makeQueryString()));
			exit;
		}
	}
}

My 2 cents,

pascal

 

P.S. Some Initial info on cookies and sessions here:

http://blog.themeforest.net/tutorials/working-with-sessions-and-cookies-in-php-and-mysql/

Link to comment
Share on other sites

Hi Jason,

Code in 1.5 impies that it DOES use $_SESSION, or at least has knowledge of sessions:

 

for example in:

<your admin folder>/ajaxfilemanager/inc/config.php

 

the code to start a session is found:

if(!isset($_SESSION))
{
  session_start();
}
 
 
and in 
 
<your admin folder>/ajaxfilemanager/ajax_login.php:
if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] === false) {
	
	if(isset($_POST['username']))
	{
		if($auth->login())
		{
			header('Location: ' . appendQueryString(CONFIG_URL_HOME, makeQueryString()));
			exit;
		}
	}
}

My 2 cents,

pascal

 

P.S. Some Initial info on cookies and sessions here:

http://blog.themeforest.net/tutorials/working-with-sessions-and-cookies-in-php-and-mysql/

 

Thank you so much.

I will glean this article.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...