PDA

View Full Version : Set Cookie for browser session only



waltcamp
06-22-2002, 07:12 PM
Greetings,
What do I need to change here so that when the popup loads it will not reload when a visitor returns to the page during a visit. I want it to load the next time they start a new session.

TIA and regards...
Walt...


function getCookie(NameOfCookie){
if (document.cookie.length > 0) {
begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1) {
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end));
}
}
return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function DoTheCookieStuff()
{
visited=getCookie('visited');
if (visited==null)
{
setCookie('visited','yes',365)
MyWindow=window.open('http://www.c-spotco.com/weather_page.htm','MyWindow','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollb ars=yes,resizable=yes,width=640,height=480,left=1,top=1');
}
}

joh6nn
06-22-2002, 07:43 PM
function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

try getting rid of the parts in bold. that should do it, but i'm tired, and didn't take a real thorough look.

waltcamp
06-25-2002, 10:22 PM
Thank you joh6nn.

I did as you suggested but still now joy.

I also deleted this line:
"; expires=Thu, 01-Jan-70 00:00:01 GMT";

also with no luck. Have you another suggestion?
I'll keep trying too....

Regards...

jtr
06-26-2002, 12:56 AM
Take a look here:
http://wsabstract.com/popwin/index.shtml

Step 3 has a once only per browser session.

waltcamp
06-26-2002, 02:00 AM
Thank you jtr, just right!!!

Regards....
:D