BrianG Posted October 3, 2009 Share Posted October 3, 2009 Hi. I've been searching google forever trying to figure this out, finally breaking down and asking somewhere. I have a site with a user area, standard fare. I have it sending cookies and everything, but it seems like after a day or so I get logged out, even though the cookie is still there, the session is still in my tmp folder, and the session is the same as the cookie. I don't know where it's going wrong. I'd like it to stay logged in until the user logs out. this is what i have: session_name("cookieexample"); session_set_cookie_params(155520000,"/"); session_start(); When i look in my cookies I see the cookie name "cookieexample" with an expiration time of like 14 years, and the session id. but I guess it's still unregistering my session variables after like a day. why is this? am i doing something wrong? it looks like i'm doing everything the exact same as all the tutorials I've seen, why wont it keep me logged in? Link to comment https://forums.phpfreaks.com/topic/176361-need-help-with-php-sessionscookies/ Share on other sites More sharing options...
ngreenwood6 Posted October 3, 2009 Share Posted October 3, 2009 I think you want to set the cookie like this: setcookie('name','value',time()+3600*24*7); of course you would replace name with the name for the cookie and value with the value you want stored for the cookie Link to comment https://forums.phpfreaks.com/topic/176361-need-help-with-php-sessionscookies/#findComment-929545 Share on other sites More sharing options...
BrianG Posted October 3, 2009 Author Share Posted October 3, 2009 what does that do that session_set_cookie_params() doesnt? As far as I can tell from googling setcookie is what you use to change a cookie that is already sent. I'm not having problems with the sending/setting of the cookie, it's there and has all the values I want, for some reason my sessions just aren't be saved/retreived. I dunno if this is a cookie problem, a setting problem, or something that I'm just totally missing, but every tutorial site I've found just says session_name() session_set_cookie_params() session_start() and then any $_SESSION['variables'] I set should last as long as the cookie lasts. Link to comment https://forums.phpfreaks.com/topic/176361-need-help-with-php-sessionscookies/#findComment-929551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.