By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,685 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,685 IT Pros & Developers. It's quick & easy.

Unable to retrieve cookie set via javascript

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.