• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1325
  • Last Modified:

overwrite cookie

need help, this is not overwriting the cookie value...

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

0
testn1
Asked:
testn1
1 Solution
 
nauman_ahmedCommented:
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
 
testn1Author Commented:
nope.. keeps the same value...
0
 
testn1Author Commented:
i'm trying to overwrite it, it already exists... even if i recreate it, keep the same value
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
testn1Author Commented:
and even if i expire it : Response.Cookies("webFASBizID").Expires = DateTime.Today.AddDays(-1)

still exists with the value
0
 
nauman_ahmedCommented:
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
 
shovavnikCommented:
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
 
DotNetLover_BaanCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now