Results 1 to 3 of 3

Thread: Session Cookies - Possible??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Location
    Dayton, OH USA
    Posts
    119

    Session Cookies - Possible??

    Is it possible to create a session cookie. In other words, a cookie that is created, then destroyed when the session ends or the browser is closed? I tried to create a cookie with no expiration date, but that did not work.

    Probably a dumb question, but....

    Thanks in advance...

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Re: Session Cookies - Possible??

    Well, I guess to create a "session cookie" - you can set the expiry of teh cookie to NOW+ 20 (20 been the session timeout of your application)

    But instead of that I would suggest you to use the session variables instead of "this" kind of a cookie.

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Session Cookies - Possible??

    Take a look at the SessionState element in the web.config file. You can set the Timout property of this element, or terminate the session (using authentication etc.) to delete the cookie when it's no longer needed.

    FROM MSDN:
    You might also want to specify the cookie's expiration date and time. Cookies are normally written to the user's disk, where they could potentially hang around forever. You can therefore specify a date and time on which the cookie expires. When the user visits your site again, the browser first examines the collection of cookies for your site. If a cookie has expired, the browser does not send that particular cookie to the server with the page request; instead, the expired cookie is deleted. (Your site might have written multiple cookies to the user's computer; each cookie can have a separate expiration date and time.) Notice that the browser is responsible for managing cookies on the hard disk, a fact that affects what you can do with cookies in your application, as I will explain shortly.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width