Try something like that:
if (Request.Cookies["userId"] != null)
{
Response.Cookies["userId"].Expires = DateTime.Now.AddDays(-1);
}
But it also makes sense to use
Session.Abandon();
besides in many scenarios.
More Related Contents:
- What is the difference between a Session and a Cookie in ASP.net?
- Session Variable with if/else statement in Views?
- Keeping ASP.NET Session Open / Alive
- Web app blocked while processing another web app on sharing same session
- How to set session timeout in web.config
- Advantages of Cache vs Session
- Access HttpContext.Current from different threads
- HttpContext.Current.Session is null in Ashx file
- What is the best way to determine a session variable is null or empty in C#?
- C# keep session id over httpwebrequest
- Check if Cookie Exists
- How to Kill A Session or Session ID (ASP.NET/C#)
- How to share sessions between PHP and ASP.net application?
- Unable to serialize the session state
- How to secure the ASP.NET_SessionId cookie?
- C# Clear Session
- how safe is it to use session variables – asp.net / c#
- Can OWIN middleware use the http session?
- ‘Session’ does not exist in the current context
- Passing array of strings to webmethod with variable number of arguments using jQuery AJAX
- How to make LINQ execute a (SQL) LIKE range search
- How to debug a single thread in Visual Studio?
- How can I get date and time formats based on Culture Info?
- ConfigurationManager.AppSettings getting null?
- MEF with MVC 4 or 5 – Pluggable Architecture (2014)
- ThreadStaticAttribute in ASP.NET
- AutoMapper Migrating from static API
- Datetime format Issue: String was not recognized as a valid DateTime
- Limit only one session per user in ASP.NET
- Why are Static Methods not Usable as Web Service Operations in ASMX Web Services?