• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Can only read javascript cookie with .net in directory it was created?

I have a cookie set on landing page with javascript like below:

...
setCookie('cSizeSpeed', speedsize, 1);
...

   function setCookie(c_name, value, exdays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
        document.cookie = c_name + "=" + c_value;
    }

Open in new window


I can read it on the next page using this vb code, but only if that page is in the same directory where the javascript created it. How can I overcome this limitation?

       
   If Not IsNothing(Request.Cookies("cSizeSpeed")) Then
                strSpeedSize = Request.Cookies("cSizeSpeed").Value
        End If

Open in new window

0
hitman3030
Asked:
hitman3030
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
I believe that the default is to set the path to the current directory.  This page http://stackoverflow.com/questions/5045053/set-cookie-wih-js-read-with-php-problem has examples of setting the path to '/' which is the root directory of the web site.  That should make it readable by any file at the web root or it's subdirectories.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now