fanfavorite Posted November 6, 2007 Share Posted November 6, 2007 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 More sharing options...
atlanta Posted November 6, 2007 Share Posted November 6, 2007 Yea use php to set your session variable as showed here http://us2.php.net/session look over that link . if you need help let us know` Link to comment https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-385913 Share on other sites More sharing options...
fanfavorite Posted November 6, 2007 Author Share Posted November 6, 2007 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 https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-385932 Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 The Cookie on the user's machine or the Session ID in your Sessions folder on your webhost? Link to comment https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-385989 Share on other sites More sharing options...
atlanta Posted November 6, 2007 Share Posted November 6, 2007 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 https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-385991 Share on other sites More sharing options...
fanfavorite Posted November 6, 2007 Author Share Posted November 6, 2007 Ok thanks Atlanta. What apps do you use to search through php files? Link to comment https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-386003 Share on other sites More sharing options...
atlanta Posted November 6, 2007 Share Posted November 6, 2007 http://www.rjlsoftware.com/software/utility/search/download.shtml download that have it setup to only read php files in a directory then have a search string and replace. if you need a pic on how to set it up ill post one up let me know Link to comment https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-386015 Share on other sites More sharing options...
fanfavorite Posted November 6, 2007 Author Share Posted November 6, 2007 Great thanks! Link to comment https://forums.phpfreaks.com/topic/76246-solved-cookie-as-sessions-not-expiring/#findComment-386024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.