Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing cookies

Status
Not open for further replies.

ashaig

Programmer
Apr 9, 2001
26
GB
Hi,

I'm setting up a cookie at the beginning of a long-winded application (lots of data entry) and by the time I want to retrieve it (maybe 30 minutes later) to save to database its gone!
I've tried setting Expires property to 2 days in advance to no avail. Code is below - the Response.Cookies statement is at bottom. Any suggestions gratefully received.


<SCRIPT language=vbscript runat=server>

Function addDate(thedate)

addDate = DateAdd(&quot;d&quot;, 2, thedate)

End Function
</SCRIPT>
</head>
<body>

<%
var dt = new Date();
var mon = dt.getMonth() + 1;
var today = dt.getDate();
var tomorrow = dt.getDate();
if (today < &quot;10&quot;)
{
today = &quot;0&quot; + dt.getDate();
}
if (tomorrow < &quot;10&quot;)
{
tomorrow = &quot;0&quot; + tomorrow;
}
var yr = dt.getFullYear();
var sdate = today + &quot;/&quot; + mon + &quot;/&quot; + yr;
var sysdate = tomorrow + &quot;/&quot; + mon + &quot;/&quot; + yr;
sysdate = addDate(sysdate);

Response.Cookies(&quot;staffid&quot;) = loRS.fields.getValue(&quot;PERSON_ID&quot;);
Response.Cookies(&quot;staffid&quot;).Expires = sysdate;
%>

 
Hey, I'm in no way a professional infact I think I forgot all I ever truly knew about Java Scipt but it seems to me that your ending your Script <Script> </Script> tags a little early But I naturally could be wrong. Becuase it has been my experience that If you exit the <Script> tags before you save anything it gets erased, and it looks like the </Scirpt> tag appears before the code ends please ignore if I'm wrong. John 3:15-16 God bless and Christ be with you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top