Forum Moderators: phranque

Message Too Old, No Replies

cache or cookie problem

when users come back to the site...

         

StuntasticAudi

11:29 pm on Aug 11, 2006 (gmt 0)

10+ Year Member



I have a website where users can login to their accounts..once they exit the website and come back they are still logged in. I dont want them to be still logged in. How do i change that?

celgins

6:01 pm on Aug 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Depends on how you're allowing them to log in. What script are you using (i.e. ASP, PHP, etc.) and are you using sessions?

rocknbil

7:18 pm on Aug 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are keeping the login with a persistent cookie, the easiest was is to set the cookie as a SESSION cookie. You do this by NOT setting an expiration date value in the cookie. When the browser is closed, the cookie dies and they must re-log in.

A session cookie WILL persist if a user does not close the browser - that is, if they go off the site, leave their browser open, then come back tomorrow they will still be logged in. If you want to avoid this, then you have to go back to setting an expire date and time in the cookie and figure out how to set it X hours ahead of the last activity.

The details of all this are too deep for a quick answer in this thread, search these forums for 'cookies' in the programming language the login scheme is using, you will find answers and examples.

celgins

9:04 pm on Aug 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A session cookie WILL persist if a user does not close the browser - that is, if they go off the site, leave their browser open, then come back tomorrow they will still be logged in.

True, but it depends on the scripting and how the sessions are defined.

For example, the default session timeout for VB (ASP) is 20 minutes and set automatically at the server level. Of course the coder has the option of increasing this timeout.

In this case, even if a user leaves their current browser open, their session will eventually timeout and they must re-login.

StuntasticAudi

1:27 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



Code is in PHP...here is what i found in the header..what do i change?

}
function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}
function getcookie(cookiename) {
var cookiestring=""+document.cookie;
var index1=cookiestring.indexOf(cookiename);
if (index1==-1 ¦¦ cookiename=="") return "";
var index2=cookiestring.indexOf(';',index1);
if (index2==-1) index2=cookiestring.length;
return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value)
{
duration=30;

cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;

}
function delcookie(name)
{
cookiestring=name+"="+escape('')+";EXPIRES="+getexpirydate(-1);
document.cookie=cookiestring;

celgins

3:02 am on Aug 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This code sets a cookie to expire at a certain date.

All you have to do is figure out how long you want the cookie to stay active.

If you would rather use sessions, Google the term: "session_start()"