views:

63

answers:

2

I have been looking on the web for some time now and HTML5 local storage seems to look like something useful to me and a solution to my problem that I am having with PHP sessions, the problem is that they are not consistent even if I set them to remember me the next time I come to my home page I am taken to the login page, this is not always, but often, PHP sessions are proving inconsistent for me.

I would like to know if i can use local storage for consistent session storage that php can use, all the examples i have seen on the web use javascript.

A: 

No. PHP runs on the server and has no access to the local storage API of the browser.

David Dorward
+4  A: 

Localstorage is for saving data client side so that it can be accessed even if the client is offline, in which case it is accessed, as you said, using JavaScript.

PHP sessions store information on the server. Using localStorage is also a bad idea because it can be modified by the client, so the client could claim to be logged in as a different user which is obviously a security issue.

Is there a problem with your PHP configuration? Is there a timeout value for the PHP session cookie that you can change?

blob8108
well i set my session cookie for 604800 seconds, thats 7 days if remember me is checked, else its a regular session that goes away when the browser exits, I am useing Zend framework, here is my line of code for it, if(!empty($this->rememberMe)) { Zend_Session::rememberMe(604800); } else { Zend_Session::forgetMe(); }thats all there is to it,i dont know what can possibly go wrong,Yes it does work,but its not consistent, it falls out randomly in a few hours, the maximum it stayed was for 2 days, it disapears even if the browser window is open
Akay
Is using the normal PHP $_SESSION variable more successful? Is it an issue with your browser?
blob8108
I did not try the raw $_SESSION, but its not a browser issue, my friends and alpha testers also notice the same issue.
Akay