Solved

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

Posted on 2013-01-05
1
333 Views
Last Modified: 2013-01-06
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
Comment
Question by:hitman3030
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38748165
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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question