Solved

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

Posted on 2013-01-05
1
322 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
1 Comment
 
LVL 82

Accepted Solution

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now