I am very new to javascript and localstorage usage for HTML5. I am currently using PHP sessions in my site and want to move over to localstorage as I am using cookies at this time to renew the sessions.
I understand that localstorage is a client-side function and not server-side like PHP so this makes it hard for me to figure out how to approach this.
All I want to do is set the localstorage values (which I have done already) but I need to be able to pass them back into PHP to re-establish them as SESSION variables (I have to do this as my site has over 100 pages and upwards of 50 session variables at one time so I would like to simply use the localstorage to regenerate the session variables instead of cookies.
If anyone can help me out with this it would be much appreciated. Thank you.
Your going to need to use ajax, or some form of way to contact your server to allow this. The only way you can access that local storage is using a client side script(javascript), which in turn can do things with it. I don’t know ajax, but you should look into that. I also agree with @Truth, local storage is nice, especially if you don’t want to use cookies, but the only benefit is the user can use that local storage offline. So theres really no real reason you should do that. If you use cookies, you can access that info through your script. You could on the other hand use local storage as an alternative to cookies being disabled on the users browser.