| |

VerySource

 Forgot password?
 Register
Search
View: 938|Reply: 8

Problems clearing cookies on exit

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-20 22:00:02
| Show all posts |Read mode
I saved cookies in the landing page
Response.Cookies ["TrueName"]. Value = sdr ["TrueName"]. ToString ();
Response.Cookies ["TrueName"]. Expires = DateTime.Now.AddMinutes (30);

Expires in 30 minutes

In the Page_Load event of the exit page
Response.Cookies.Clear ();
In this way, I can still read the cookie value on other pages, what's going on?

Later I wrote it like this
Response.Cookies ["TrueName"]. Value = "";
Response.Cookies.Clear ();

The result is still the same. The value of Cookies can still be read on other pages. Why can't it be cleared?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-30 09:18:01
| Show all posts
Response.Cookies ["TrueName"]. Value = "";
Response.Cookies ["TrueName"]. Expires = try -1 seconds;
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-30 10:36:01
| Show all posts
Expires problem.
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-30 13:45:01
| Show all posts
Response.Cookies ["TrueName"]. Value = "";
Response.Cookies ["TrueName"]. Expires = DateTime.Now.AddMinutes (-1);
Response.Cookies.Clear ();

This still doesn't work ~!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-30 15:54:01
| Show all posts
Response.Cookies ["TrueName"]. Expires = DateTime.Now;
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-30 21:27:01
| Show all posts
Or not

After reading the COOKIES page, it is a new window. Does the main window quit and the new window will not work?
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-31 10:36:01
| Show all posts
Add cookies:

HttpCookie cookie = new HttpCookie ("MyCookie");

cookie1.Values.Add ("TrueName", sdr ["TrueName"]. ToString ());

Response.Cookies.Add (cookie);

========================================

When logging out:
HttpCookie cookie = Request.Cookies ["MyCookie"];
cookie.Expires = DateTime.Now.AddDays (-1);
Response.Cookies.Add (cookie);
Reply

Use magic Report

0

Threads

15

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-1 12:54:01
| Show all posts
/// <summary>
/// delete cookie, pass value cookiename
/// </ summary>
/// <param name = "cookiename"> </ param>
public void delcookie (string cookiename)
{
HttpCookie cookie = new HttpCookie ("" + cookiename + "", null);
cookie.Expires = DateTime.Now.AddDays (-1);
System.Web.HttpContext.Current.Response.Cookies.Add (cookie);
System.Web.HttpContext.Current.Response.Cookies.Remove ("cookie");
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-13 09:00:01
| Show all posts
Learn
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list