473,507 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with cookies

I'm having trouble accessing my cookies after they're set. If I do a
response.write on the cookie value immediately after it's set in code,
it writes out the cookie value as it should. But when I come back to
the page the cookie is null and I can no longer access it.

Here's my add code:

DateTime expireCookie = DateTime.Now;
expireCookie.AddYears(5);

HttpCookie vandalayCookie = new HttpCookie("VandalayCookie");
vandalayCookie.Expires = expireCookie;
vandalayCookie.Values.Add("UserName",opUser.Select edValue);
vandalayCookie.Values.Add("Password",txtPassword.T ext);

//Write cookie out to client
Response.Cookies.Add(vandalayCookie);

Here's my retrieval code:

HttpCookie VandalayCookie = Request.Cookies["VandalayCookie"];

if (VandalayCookie != null)
{
opUser.SelectedValue = VandalayCookie.Values.Get("UserName");
txtPassword.Text = VandalayCookie.Values.Get("Password");

}

My retrieval code always evaluates the VandalayCookie as null and
never retrieve the values. I've even added my site to my list of
trusted sites and sites that I accept cookies from and still no luck.
Is there something I'm not doing right?

Thanks,
Josh
Nov 17 '05 #1
0 920

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1511
by: collie | last post by:
Hi, I have an asp page that needs to create 2 different cookies: one for the admin and one for the user. The code that I have to work with was created by someone else. the page first requires to...
18
2444
by: | last post by:
Please help. After a number of wrong turns and experiments I need advice on login management system to secure our web pages without inconveniencing our visitors or our internal staff. What I...
0
1200
by: Bennett F. Dill | last post by:
Thanks for reading. I'm having problems with cookies from asp to asp.net and back! It seems like I can set a cookie in asp.net fine, and alter it at will, as soon as asp touches it, asp.net...
3
2071
by: Calvin KD | last post by:
Hi everyone, Can someone tell me what's wrong with the way that i read a cookie as below: private void Page_Load(object sender, System.EventArgs e) { Response.Cookies.Clear(); HttpCookie...
4
1302
by: serge calderara | last post by:
Dear all, I try to make some test on how to use basic cookie but get some trouble in the sens that I was not able to read back previous cretaed cookies. In page_load event I have the following...
0
1221
by: Alan Silver | last post by:
Hello, I am having a problem setting and resetting cookies. I'm sure I just doing something really stupid as this is such a basic issue, but I can find any answer. Please can someone help me? ...
3
1815
by: Phillip N Rounds | last post by:
I'm having trouble with using cookies to monitor the stages of login. I have a two stage Registration page ( register.aspx ) and my target page ( MyPage.aspx ) I'm using a cookie named LoginStatus...
7
2620
by: isaac2004 | last post by:
hi i have a basic asp page that acts as an online bookstore. on my cart page i am having trouble generating 3 numbers; a subtotal, a shipping total, and a final price. here is my code i would...
2
2313
by: isaac2004 | last post by:
hi i am creating a basic asp site that uses cookies to manage a cart for an online store. whenever i open this page without adding anything to the cart. i get an error message. here is my code ...
6
3319
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.