mike177 Posted February 10, 2008 Share Posted February 10, 2008 Hi, I need a little help with cookies. I want m cookies on my site to never expire unless the browser is closed or the user logout. On the php site it says to set the expire to 0. I tried this and the cookie expired a few seconds later. Does any one have some suggestions. Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/ Share on other sites More sharing options...
marcus Posted February 10, 2008 Share Posted February 10, 2008 See the expire to like: time()+3600*24*365*10 That's 10 years for ya. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/#findComment-462948 Share on other sites More sharing options...
revraz Posted February 10, 2008 Share Posted February 10, 2008 You are asking for two different things. You say never to expire unless the browser is closed. Setting it to 0 or no time means it will expire when the browser closes. So do you want it to "never" expire (which is not possible) or do you want it to expire when the browser is closed? Hi, I need a little help with cookies. I want m cookies on my site to never expire unless the browser is closed or the user logout. On the php site it says to set the expire to 0. I tried this and the cookie expired a few seconds later. Does any one have some suggestions. Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/#findComment-463009 Share on other sites More sharing options...
mike177 Posted February 10, 2008 Author Share Posted February 10, 2008 You are asking for two different things. You say never to expire unless the browser is closed. Setting it to 0 or no time means it will expire when the browser closes. So do you want it to "never" expire (which is not possible) or do you want it to expire when the browser is closed? Hi, I need a little help with cookies. I want m cookies on my site to never expire unless the browser is closed or the user logout. On the php site it says to set the expire to 0. I tried this and the cookie expired a few seconds later. Does any one have some suggestions. Thanks in advance for any help. Yea I just want the cookie to expire either when the user clicks the logout link to execute the logout script or when the user closes the browser. So I want the cookie to last as long as the user is logged in. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/#findComment-463087 Share on other sites More sharing options...
rofl90 Posted February 10, 2008 Share Posted February 10, 2008 I use time()+3600*24*365*120 and on the unthinkable likeliness of them having fun on your site for 120 years, increase the '120' without quotes number. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/#findComment-463094 Share on other sites More sharing options...
cooldude832 Posted February 10, 2008 Share Posted February 10, 2008 when a log out button is clicked the cookie is deleted/unlinked from the server. Yes you are changing the cookies life to delete it, but it doesn't affect the overall life. Link to comment https://forums.phpfreaks.com/topic/90292-never-expiring-cookie/#findComment-463095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.