how to update a cookie value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajunarender01
    New Member
    • Mar 2008
    • 1

    how to update a cookie value

    hi
    i am working with the usercontrol and want to update the cookie value in the user control how to do it
  • mikeyeli
    New Member
    • Oct 2007
    • 63

    #2
    Originally posted by rajunarender01
    hi
    i am working with the usercontrol and want to update the cookie value in the user control how to do it
    To update a cookie you can do this:
    Code:
    public void setCookieValue(string key, string value)
    		{
    			HttpCookie cookie = null;
    			string cookieName = "whateverTheCookieNameIs";
    			
    			if (Request.Cookies[cookieName] != null )
    			{
    				cookie = Request.Cookies[cookieName];
    				cookie.Values[key] = value;			
    				Response.AppendCookie(cookie);
    			}			
    		}

    Comment

    Working...