Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Can't get this script to write the cookie
- From: javascript@xxxxxxxxxx (Phillip Morgan)
- Subject: [Javascript] Can't get this script to write the cookie
- Date: Fri, 31 May 2002 14:49:42 +1000
This is a multi-part message in MIME format.
------=_NextPart_000_0003_01C208B2.65F2B140
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hi,
I'm having problems getting this script to work. It is intended to grab
the query string from the URL and then write that to a cookie which is
later retrieved on another page. Can anyone help please....
<script language="JavaScript">
<!-- Hide this script from old browsers
// Set the expiry date for cookie - valid for 30 days
var expDate = new Date();
expDate.setTime( expDate.getTime() + ( 24 * 3600 * 30000 ) );
var qryString;
var myId;
var x;
qryString = window.location.search;
x = qryString.indexOf("=");
myId = qryString.substring((x + 1),qryString.length)
function setCookie( name, value ){
var argv = setCookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var Path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
( ( expires == null ) ? "" : ( "; expires=" +
expires.toGMTString() ) ) +
( ( Path == null ) ? "" : ( "; path=" + Path ) ) +
( ( domain == null ) ? "" : ( "; domain=" + domain ) ) +
( ( secure == true ) ? " ; secure" : "" );
}
// Write cookie.
setCookie('QLTReferrer',myId, expDate, cookiePath );
// -->
</script>
------=_NextPart_000_0003_01C208B2.65F2B140
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>Message</TITLE>
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D620214004-31052002>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D620214004-31052002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D620214004-31052002>I'm =
having problems=20
getting this script to work. It is intended to grab the query string =
from the=20
URL and then write that to a cookie which is later retrieved on another =
page.=20
Can anyone help please....</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D620214004-31052002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D620214004-31052002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> <script=20
language=3D"JavaScript"><BR> <!-- Hide this =
script from=20
old browsers<BR> <BR> // Set the expiry date for cookie - =
valid for 30=20
days<BR> var expDate =3D new Date();<BR><SPAN=20
class=3D620214004-31052002> </SPAN> exp=
Date.setTime(=20
expDate.getTime() + ( 24 * 3600 * 30000 ) );</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN=20
class=3D620214004-31052002> </SPAN>var <SPAN=20
class=3D620214004-31052002>qryString</SPAN>;<BR> var <SPAN=20
class=3D620214004-31052002>myId</SPAN>;<BR> var <SPAN=20
class=3D620214004-31052002>x</SPAN>;<BR> <BR> <SPAN=20
class=3D620214004-31052002>qryString</SPAN> =3D=20
window.location.search;<BR> <SPAN class=3D620214004-31052002>x=20
</SPAN>=3D <SPAN=20
class=3D620214004-31052002>qryString</SPAN>.indexOf("=3D");<BR> <SPA=
N=20
class=3D620214004-31052002>myId</SPAN> =3D <SPAN=20
class=3D620214004-31052002>qryString</SPAN>.substring((<SPAN=20
class=3D620214004-31052002>x</SPAN> + 1),<SPAN=20
class=3D620214004-31052002>qryString</SPAN>.length)</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> function setCookie( name, value=20
){<BR> <SPAN=20
class=3D620214004-31052002> </SPAN> var argv =
=3D=20
setCookie.arguments;<BR> <SPAN=20
class=3D620214004-31052002> </SPAN>var argc =3D=20
setCookie.arguments.length;<BR><SPAN=20
class=3D620214004-31052002> </SPAN> var=
expires=20
=3D (argc > 2) ? argv[2] : null;<BR><SPAN=20
class=3D620214004-31052002> </SPAN> var=
Path =3D=20
(argc > 3) ? argv[3] : null;<BR><SPAN=20
class=3D620214004-31052002> </SPAN> var=
domain =3D=20
(argc > 4) ? argv[4] : null;<BR><SPAN=20
class=3D620214004-31052002> </SPAN> var=
secure =3D=20
(argc > 5) ? argv[5] : false;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> <SPAN=20
class=3D620214004-31052002> </SPAN> document.cookie =3D name + =
"=3D" + escape=20
(value) +<BR> <SPAN=20
class=3D620214004-31052002> </SPAN>( ( expires =3D=3D =
null ) ? "" :=20
( "; expires=3D" + expires.toGMTString() ) ) +<BR><SPAN=20
class=3D620214004-31052002> </SPAN> &nb=
sp; (=20
( Path =3D=3D null ) ? "" <SPAN =
class=3D620214004-31052002> =20
</SPAN>: ( "; path=3D" + Path ) ) +<BR><SPAN=20
class=3D620214004-31052002> </SPAN> &nb=
sp; (=20
( domain =3D=3D null ) ? "" : ( "; domain=3D" + domain ) ) =
+<BR><SPAN=20
class=3D620214004-31052002> </SPAN> &nb=
sp; (=20
( secure =3D=3D true ) ? "<SPAN =
class=3D620214004-31052002> </SPAN>;=20
secure" : "" );<BR><SPAN=20
class=3D620214004-31052002> </SPAN> }</=
FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> // Write=20
cookie.<BR>setCookie('QLTReferrer',my<SPAN =
class=3D620214004-31052002>Id</SPAN>,=20
expDate, cookiePath );</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><SPAN class=3D620214004-31052002><FONT face=3DArial size=3D2>//=20
--></FONT></SPAN></DIV>
<DIV><SPAN class=3D620214004-31052002><FONT face=3DArial=20
size=3D2></script></FONT></SPAN></DIV></BODY></HTML>
------=_NextPart_000_0003_01C208B2.65F2B140--
- Prev by Date: [javascript] UNSUBSCRIBE
- Next by Date: [Javascript] Can't get this script to write the cookie
- Previous by thread: [Javascript] How To Unsubscirbe
- Next by thread: [Javascript] Can't get this script to write the cookie
- Index(es):