Jump to content

Need help with php sessions/cookies


BrianG

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.