Jump to content

[SOLVED] Cookie As Sessions Not Expiring


fanfavorite

Recommended Posts

I read somewhere that if you set a cookie with the expiry value of 0, it becomes a session variable.  I have done so below:

 

setcookie("login",$username,0,"/",false);

 

It removes the cookie on browser close, however when other session variables expire because the user is inactive, the cookie is still active.  Any ideas on what I need to do to make it expire with inactivity as well?     

 

Thanks!

 

-JC  

Link to comment
https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/
Share on other sites

Thanks for your post.  I am aware of how to set and use sessions, but will I have to do it as session to begin with rather than a cookie?  The reason I don't want to do this is that our system is huge and has references like $_COOKIE[login] throughout.  If I change it, I will have to go through everything and change is to $_SESSION[login].

 

Is there no way to make the cookie act exactly like a session variable and expire when inactive as well?   

Yea you will have to do it as a session throughout if you want it to work that way..

I have some apps that will go through php files and change certain strings..

if you dont wanna do it this way then have the cookie expire after a period of time, do a survey and see how long the average user stays on.. just throwing some ideas out there

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.