Zepo. Posted December 21, 2007 Share Posted December 21, 2007 Im not sure if its my browser doing this or what, but the cookie only seems to last as long as a session does. Heres the code. Select <select class='button' name='login[clength]'> <option value='60'>1 Hour</option> <option value='1440'>1 Day</option> <option value='10080'>1 Week</option> <option value='43200'>1 Month</option> <option value='-1' selected='selected'>Forever</option> </select> Cookie Set setcookie(tid, $getid[id], $login[clength]); setcookie(user, $login[name], $login[clength]); setcookie(pass, $login[pass], $login[clength]); Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/ Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 setcookie ('tid', $getid[id], time () + (60*$login[clength]),'/'); That is the idea you want to do, not sure if it will parse your variables right or not though like that. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420720 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 I dont think its parsing them, because it doesnt even set the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420792 Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 There is no setting that will last forever. Make the last option a year. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420793 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 Well, the code isnt working. Doesnt set them. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420796 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 Any other way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420841 Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 You don't say how any of these get set. Are you using a FORM? I don't see where $login[clength] = login[clength] Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420847 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 Yes im using a form, my old way of doing it was working, but it just expired after about a day. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420849 Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 First you stated it expired when you closed the browser, now you say it lasted for a day. Lets make sure variables are set. If you echo $login[clength], what is the value when you set the cookie? The time value is based on Seconds, it looks like you are treating it as minutes, thats why I added the extra 60* in there Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420852 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 It echos the same value as selected. Im not sure if i was, but it never really had a defined lench, it seemed to go away when it wanted to. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420859 Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 Try using it without variables setcookie ('tid', $getid['id'], time () + (60*60*24*365),'/'); Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420865 Share on other sites More sharing options...
Zepo. Posted December 21, 2007 Author Share Posted December 21, 2007 Doesnt work either. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420876 Share on other sites More sharing options...
Zepo. Posted December 22, 2007 Author Share Posted December 22, 2007 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420930 Share on other sites More sharing options...
Zepo. Posted December 22, 2007 Author Share Posted December 22, 2007 setcookie(tid,$getid[id],time() + time() + 60 * $login[clength]); setcookie(user,$login[name],time() + 60 * $login[clength]); setcookie(pass,$login[pass],time() + 60 * $login[clength]); The best i could come up with, still doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420964 Share on other sites More sharing options...
revraz Posted December 22, 2007 Share Posted December 22, 2007 You didn't even enter it as I posted. Try copy/paste instead of typing it, since you are leaving out a few things. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420971 Share on other sites More sharing options...
Zepo. Posted December 22, 2007 Author Share Posted December 22, 2007 I tried it as you posted it, still didnt work. Quote Link to comment https://forums.phpfreaks.com/topic/82718-cookie-length-question/#findComment-420974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.