469,353 Members | 2,113 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

Help With Cookie Expiry

Hi i have a snippet of JS that i want to change so that the cookie it
creates lasts only 48 hours. (or any other length of time i decide, but
48hours seems right for now)

Only thing i can't figure out how it specifies the expiry time.

Thanks!

Hardeep

-----
function makeCookie(Name,Value,Expiry,Path,Domain,Secure){
if (Expiry != null) {
var datenow = new Date();
datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
Expiry = datenow.toGMTString();
}

Expiry = (Expiry != null) ? '; expires='+Expiry : '';
Path = (Path != null)?'; path='+Path:'';
Domain = (Domain != null) ? '; domain='+Domain : '';
Secure = (Secure != null) ? '; secure' : '';

document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain
+ Secure;
}

function readCookie(Name) {
var cookies = document.cookie;
if (cookies.indexOf(Name + '=') == -1) return null;
var start = cookies.indexOf(Name + '=') + (Name.length + 1);
var finish = cookies.substring(start,cookies.length);
finish = (finish.indexOf(';') == -1) ? cookies.length : start +
finish.indexOf(';');
return unescape(cookies.substring(start,finish));
}

function setActiveStyleSheet(pTitle) {
var vLoop, vLink;
for(vLoop=0; (vLink = document.getElementsByTagName("link")[vLoop]);
vLoop++) {
if(vLink.getAttribute("rel").indexOf("style") != -1 &&
vLink.getAttribute("title")) {
vLink.disabled = true;
if(vLink.getAttribute("title") == pTitle) vLink.disabled = false;
}
}
}

function selectStyle (vCookieName, vSelection) {
//WRITE COOKIE
makeCookie(vCookieName, vSelection, 90, '/');
//ACTIVE SELECTED ALTERNAT STYLE SHEET
setActiveStyleSheet(vSelection)
}

if (document.cookie.indexOf('style')!=-1) {
css = readCookie('style');
//ACTIVATE SELECTED STYLE SHEET
setActiveStyleSheet(css)
}
Jul 20 '05 #1
1 1829
Hardeep Rakhra wrote:
Hi i have a snippet of JS that i want to change so that the cookie it
creates lasts only 48 hours. (or any other length of time i decide, but
48hours seems right for now)


One other thing, seem this won't work with Firebird 0.7

It's from;

http://www.notestips.com/80256B3A007F2692/1/NAMO5GK2NM

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by What-a-Tool | last post: by
5 posts views Thread by brettr | last post: by
4 posts views Thread by Aki | last post: by
9 posts views Thread by Marco Krechting | last post: by
6 posts views Thread by mymatebob | last post: by
1 post views Thread by Stef | last post: by
7 posts views Thread by cmrchs | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.