It is assumed that we have two users: user 1,user 2
I want to user 1send a request to change the cookie value, the cookie value user 2has changed.
Here is my code in the class:
public static void changeCookieCount(Int64 targetUserId)
{
int a =
HttpCookie cookieCount = HttpApp.RequestCookie("cookieCount");
if (cookieCount != null)
{
cookieCount.Value = a;
cookieCount.Expires = DateTime.Now.AddSeconds(5);
cookieCount.Expires = DateTime.Now.AddMonths(2);
cookieCount.Secure = true;
HttpApp.ResponseCookie(cookieCount);
}
else
{
cookieCount = new HttpCookie("cookieCount");
cookieCount.Value = a;
cookieCount.Expires = DateTime.Now.AddSeconds(5);
cookieCount.Expires = DateTime.Now.AddMonths(2);
cookieCount.Secure = true;
HttpApp.ResponseCookie(cookieCount);
}
}
As you can see, I am changing the value of the cookie in the class with the user HttpApp, and this is part of the "HttpApp":
public class HttpApp: HttpApplication
{
public static void ResponseCookie(HttpCookie cookie)
{
HttpContext.Current.Response.Cookies.Add(cookie);
}
public static HttpCookie RequestCookie(string name)
{
return HttpContext.Current.Request.Cookies[name];
}
}
My question is: how to access the target user to change the cookie value?
source
share