Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Here is the ASP Page:

 


<html>

<head>
<%
Response.cookies ("TestCookie") = "This is a test cookie"
%>
<%
Dim strASPCookie 'as string
Dim strASPXCookie 'as string

strASPCookie = Request.Cookies ("ResCookie")
strASPXCookie = Request.Cookies ("TestCookie")
%>
</head>

<body>
The Resolution Cookie is: <%=strASPCookie %>  <br />
The Test Cookie is: <%=strASPXCookie %>    

</body>

</html>

 

Here is the ASPX Page:

'in the code behind
Dim objTestCookie = Request.Cookies("TestCookie")
         
 If Not objTestCookie Is Nothing Then
       Dim strASPTestCookie As String = objTestCookie.Value
       Dim lblTestCookie As New Label
       lblTestCookie.Text = strASPTestCookie
       pnlSpace.Controls.Add(lblTestCookie)
 End If
'in the script section in the header
<script language="javascript">
<!--
function GetRes(){
   var X;
   var y;
   var name;
   x = screen.width;
   y = screen.height;
   
   name="ResCookie"
   var value = x + "|" + y;
   var exdate=new Date();
   exdate.setDate(exdate.getDate()+1);
   
   document.cookie = name + "=" + escape (value) + 
       "; expires=" + exdate;
}

//-->
window.onload=GetRes()

 

I can't read the ResCookie from the ASP page, but it can read the cookie that it just created

 

The ASPX page can read the Javascript created cookie, but not the one created by the ASP page

 

Anyone see somewhere that I am tripping up in this?

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...