Skip to content

Instantly share code, notes, and snippets.

@sajinct
Created December 30, 2013 13:28
Show Gist options
  • Save sajinct/8182103 to your computer and use it in GitHub Desktop.
Save sajinct/8182103 to your computer and use it in GitHub Desktop.
Save Object To Cookie
string myObjectJson = new JavaScriptSerializer().Serialize(myObject);
var cookie = new HttpCookie("myObjectKey", myObjectJson)
{
Expires = DateTime.Now.AddYears(1)
};
HttpContext.Response.Cookies.Add(cookie);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment