How do I create a session-only cookie?

Last post 04-19-2008 5:08 AM by gopalanmani. 2 replies.

Sort Posts:

  • How do I create a session-only cookie?

    04-18-2008, 8:31 PM
    • Member
      12 point Member
    • phizz
    • Member since 05-24-2006, 8:09 PM
    • Posts 17
    I want to create a cookie on an ASP.NET web form which expires at the end of the user's session i.e. I do not want to explicitly give it an expiry date. How do I do this?
  • Re: How do I create a session-only cookie?

    04-18-2008, 8:54 PM
    Answer
    • Participant
      1,126 point Participant
    • vishalbade
    • Member since 02-12-2008, 6:28 PM
    • Posts 187

    why not use Session("someKey")= "someValue";

    Please read this article for related information. http://geekswithblogs.net/lbugnion/archive/2007/02/25/107243.aspx

    Vishal
  • Re: How do I create a session-only cookie?

    04-19-2008, 5:08 AM
    • Contributor
      3,876 point Contributor
    • gopalanmani
    • Member since 07-28-2006, 10:45 AM
    • Posts 659

     

    hi,

    Session["SessionVal"] = "test";

    You can use session variable. When where user's session expires, it’s automatically cleared and also you can clear the all the session values in Session_End() in web.config. 
     void Session_End(object sender, EventArgs e) 
        {
            

    Session.Abandon(); or

    Session.Clear();

    }
     
     
Page 1 of 1 (3 items)