P
Pete Davis
I've never done anything with cookies. What I'm trying to do is very
straight-forward, but for some reason, it just doesn't seem to want to work.
I have a helper class with some static methods. Two are for setting and
getting the name of the user to/from a cookie:
public static string GetSiteUser(HttpRequest request)
{
HttpCookie userCookie = request.Cookies["SiteUser"];
if (null == userCookie || null == userCookie.Value)
{
return "";
}
return userCookie.Value;
}
public static void SetSiteUser(HttpResponse response, string user)
{
HttpCookie userCookie = response.Cookies["SiteUser"];
userCookie.Expires = DateTime.Now.AddYears(1);
userCookie.Value = user;
}
I call SetSiteUser() but it doesn't seemto be writing the cookie (I checked
the actual cookie file)
The only thing I can think of is that right after I call SetSiteUser, I'm
calling:
Response.Redirect(Request.RawUrl);
Which, as long as I'm here, is there a better way to force a page to
refresh?
Essentially what I've got is something like a blog comment page. You type in
a title, your name (with the option of "Remember me", and an area for
comments. When you click submit, it should refresh the page to show all the
comments (including the ones just added).
Thanks for any help.
Pete
straight-forward, but for some reason, it just doesn't seem to want to work.
I have a helper class with some static methods. Two are for setting and
getting the name of the user to/from a cookie:
public static string GetSiteUser(HttpRequest request)
{
HttpCookie userCookie = request.Cookies["SiteUser"];
if (null == userCookie || null == userCookie.Value)
{
return "";
}
return userCookie.Value;
}
public static void SetSiteUser(HttpResponse response, string user)
{
HttpCookie userCookie = response.Cookies["SiteUser"];
userCookie.Expires = DateTime.Now.AddYears(1);
userCookie.Value = user;
}
I call SetSiteUser() but it doesn't seemto be writing the cookie (I checked
the actual cookie file)
The only thing I can think of is that right after I call SetSiteUser, I'm
calling:
Response.Redirect(Request.RawUrl);
Which, as long as I'm here, is there a better way to force a page to
refresh?
Essentially what I've got is something like a blog comment page. You type in
a title, your name (with the option of "Remember me", and an area for
comments. When you click submit, it should refresh the page to show all the
comments (including the ones just added).
Thanks for any help.
Pete