Jump to content

Recommended Posts

Everything I create in PHP, and when using $_SESSION, will just fail to work if cookies are off.

 

I notice that with many sites, including phpfreaks.com that it will automatically append the session id to the URL if cookies are off. So you can still log in and use PHP Freaks even if cookies are turned off in the browser.

 

I know the security risks of this, but I want it to use cookies if the browser settings allow it, but fall back to setting the value in the URL if they are not.

 

I can't get PHP to automatically do this, so what should I do? I just need to get PHP to register the value in the URL (if cookies are off), where as at the moment it just doesn't maintain the session if cookies are off.

 

I'm guessing an answer might be something like: (1) append phpsessid=123 etc. to the URL and (2) add a certain setting to php.ini.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/267838-managing-sessions-without-cookies/
Share on other sites

I'd imagine the chances of supporting that while having cookies disabled is pretty small.

 

Plus, the only thing PHP stores in the cookie is the session ID.

 

I think that a user having cookies disabled is a rare enough event that passing it to the query string is good enough. Or, you could just display a message saying the site will only work properly if they have cookies enabled.

Scootstah, thanks for all the help btw.

 

I'm just thinking that if they have cookies disabled then they may have JS enabled. In that case, use JS and local storage to maintain the session id.

 

Local storage of course doesn't need cookies enabled at all.

 

My only problem would be how I would pass the local storage value to the server.

 

I'm sure it could be done and would prevent having the less secure option of the session id in the URL.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.