Page 1 of 1

Check if session expired

Posted: Fri Jul 23, 2010 11:47 am
by dimxasnewfrozen
I am creating a cookie

Code: Select all

setcookie("USERID","$userid",time()+3600,"/",".mydomain.org",0);
If the cookie expires, it will just go back to the log in page. I need to show some sort of indication that the cookie expired instead of just showing the log in page. Ex: "Your session has expired. Please log back in." Is there a way of detecting that the cookie expired?

Re: Check if session expired

Posted: Fri Jul 23, 2010 12:31 pm
by Jade
Just check to see if they have the cookie and if the http_referrer came from your website. If there's no cookie and the referrer was your own website then you know they were logged in but the session expired.