473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 5307
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chung Leong | last post by:
My contribution to the comp.lang.php FAQ: ------------------------------------------------------------- Q: How do I retrieve a page from a web site? A: Pass a URL to file() or...
5
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window...
9
by: Colin Graham | last post by:
hi folks, just wonder if this is possible or is there a better way of doing this. i need to store values in cookies between two forms. the details are added in a popup when this is closed the...
3
by: James Geurts | last post by:
This is probably more of an ASP.Net situation rather than c#, but since all of my code behind is in c#, maybe it fits here. I'm wondering, generally, at what point is it too inefficient to store...
6
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
1
oranoos3000
by: oranoos3000 | last post by:
hi i want to set cookie with javascript i use this code <script language="javascript"> document.cookie="username='ali'"; </script> with using this code when i look at previous cookie that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.