Solved

overwrite cookie

Posted on 2004-08-17
7
1,283 Views
Last Modified: 2012-06-21
need help, this is not overwriting the cookie value...

Response.Cookies("ID").Value = ID   ....

0
Comment
Question by:testn1
7 Comments
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 500 total points
ID: 11820529
Try this:

If (Request.Cookies("ID") != null)
{
  HttpCookie ck = new HttpCookie("ID",Request.Cookies("ID"));
  //Set expiration time.
  Response.Cookies.Add(ck);
}

Best, Nauman
0
 

Author Comment

by:testn1
ID: 11820573
nope.. keeps the same value...
0
 

Author Comment

by:testn1
ID: 11820589
i'm trying to overwrite it, it already exists... even if i recreate it, keep the same value
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:testn1
ID: 11820594
and even if i expire it : Response.Cookies("webFASBizID").Expires = DateTime.Today.AddDays(-1)

still exists with the value
0
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 11820741
Have a look at the following article that best describes about cookie. Also its not good to just expire cookie by DateTime.Today.AddDays(-1). Use DateTime.Today.AddYears(-30) so that it will be expired no matter what time difference is there.

URL: http://www.codeproject.com/aspnet/AspNetCookies.asp?df=100&forumid=13312&exp=0&select=638073

Best, Nauman
0
 
LVL 8

Expert Comment

by:shovavnik
ID: 11820866
Are you running both asp and asp.net together?

If so, keep in mind that they do not automatically share their cookies.  asp.net cannot automatically use cookies set in asp.  You can add the following line to your Page_Load method:
Response.Cookies.Set( Request.Cookies.Get( "MY_COOKIE" ));
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11820903
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …

830 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