469,958 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

Unable to retrieve cookie set via javascript

As of now I am setting a cookie on my aspx page via javascript,

function SetCookie(cookieName, value, minutesToExpire)
{
ClearCookie(cookieName);

var expireDate = new Date();
var cookieValue;
expireDate.setMinutes(expireDate.getMinutes() +
minutesToExpire);
cookieValue = cookieName + "=" + escape(value) +
";expires=" + expireDate.toGMTString();
document.cookie = cookieValue;

}

I know the cookie is created and set correctly (thx to a nifty cookie
manager). After the cookie is set, i have the javascript redirect the
user to a second aspx page. This second page is where I'm trying to
retrieve the cookie

HttpCookie cookie = Response.Cookies.Get("myCookieName");

But the code either shows that there is no cookie set, or that the
value is empty. Any ideas? Should i be setting a path for the cookie
or am i totally off base here? Any/all thoughts and solutions are
welcome.

Thanks,
Josh T

Jun 9 '07 #1
2 5127
On Jun 9, 4:59 am, Josh T <joshticha...@gmail.comwrote:
>
HttpCookie cookie = Response.Cookies.Get("myCookieName");
HttpCookie cookie = Request.Cookies.Get("cookieName");

Jun 9 '07 #2
Josh T wrote:
As of now I am setting a cookie on my aspx page via javascript,

function SetCookie(cookieName, value, minutesToExpire)
{
ClearCookie(cookieName);

var expireDate = new Date();
var cookieValue;
expireDate.setMinutes(expireDate.getMinutes() +
minutesToExpire);
cookieValue = cookieName + "=" + escape(value) +
";expires=" + expireDate.toGMTString();
document.cookie = cookieValue;

}

I know the cookie is created and set correctly (thx to a nifty cookie
manager). After the cookie is set, i have the javascript redirect the
user to a second aspx page. This second page is where I'm trying to
retrieve the cookie

HttpCookie cookie = Response.Cookies.Get("myCookieName");

But the code either shows that there is no cookie set, or that the
value is empty. Any ideas? Should i be setting a path for the cookie
or am i totally off base here? Any/all thoughts and solutions are
welcome.

Thanks,
Josh T
Try Request.Cookies instead of Response.Cookies

--

Riki
Jun 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chung Leong | last post: by
5 posts views Thread by David Rasmussen | last post: by
6 posts views Thread by kelvlam | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.