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
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?   

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.