chevys Posted April 14, 2009 Share Posted April 14, 2009 I have a site that sets 2 cookies the first one is: setcookie("trupimp",$user[2]); The second is the following: setcookie("trupimpn",$player[1]); How do i format these 2 cookies to expire if the browser is ever closed? Thanks to anyone that can assist me. [Player1] inserts the cookie into the database table [user2] inserts the cookie into another table on the database Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/ Share on other sites More sharing options...
ober Posted April 14, 2009 Share Posted April 14, 2009 You cannot detect when the browser is closed with PHP so the only thing you can do is set a specific time limit (15 minutes) on the cookie. setcookie Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/#findComment-810053 Share on other sites More sharing options...
jackpf Posted April 14, 2009 Share Posted April 14, 2009 If you set the expiry to 0 it acts like a session cookie and expires when the browser is closed. Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/#findComment-810076 Share on other sites More sharing options...
ober Posted April 14, 2009 Share Posted April 14, 2009 If you set the expiry to 0 it acts like a session cookie and expires when the browser is closed. Heh. Thanks jackpf. I wasn't aware of that. Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/#findComment-810088 Share on other sites More sharing options...
chevys Posted April 14, 2009 Author Share Posted April 14, 2009 When you add: time()+0 You have to attempt to log in several times so if you set it to 1 it will alow you to log in then if you close the browser you cannot log back in. I guess it only makes it valid for 1 second. Thanks, Guys Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/#findComment-810105 Share on other sites More sharing options...
jackpf Posted April 14, 2009 Share Posted April 14, 2009 Lol, learn something new every day. And no, not time() + 0, just 0. If you put 0 on its own as the expiry date, it will act like a session. Link to comment https://forums.phpfreaks.com/topic/154101-cookie-help/#findComment-810122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.