Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Check if Session is still alive

Check if Session is still alive

Scheduled Pinned Locked Moved ASP.NET
databasesysadminwindows-adminquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Herman T Instance
    wrote on last edited by
    #1

    Well.. this is not the simplle check if Session == null. In a global.asax file I log in a table the sessionID of a user. In the Session_End i add to that logline the date the session expired. well that works! But if a user chooses to close the browser in stead of logging out of an application....The additional logline with date session expiration is not saved. In an overview page I see that according to the database some sessions are days old while the session timeout is set for 2 hours. When I retrieve the data from the database is it possible to check with the IIS server if the found SessionID in the database is still valid for IIS?

    In Word you can only store 2 bytes. That is why I use Writer.

    M N N 3 Replies Last reply
    0
    • H Herman T Instance

      Well.. this is not the simplle check if Session == null. In a global.asax file I log in a table the sessionID of a user. In the Session_End i add to that logline the date the session expired. well that works! But if a user chooses to close the browser in stead of logging out of an application....The additional logline with date session expiration is not saved. In an overview page I see that according to the database some sessions are days old while the session timeout is set for 2 hours. When I retrieve the data from the database is it possible to check with the IIS server if the found SessionID in the database is still valid for IIS?

      In Word you can only store 2 bytes. That is why I use Writer.

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Does this CP article give you any ideas? ASP.NET HttpModule for handling session end with StateServer[^]

      www.MishaInTheCloud.com

      H 1 Reply Last reply
      0
      • H Herman T Instance

        Well.. this is not the simplle check if Session == null. In a global.asax file I log in a table the sessionID of a user. In the Session_End i add to that logline the date the session expired. well that works! But if a user chooses to close the browser in stead of logging out of an application....The additional logline with date session expiration is not saved. In an overview page I see that according to the database some sessions are days old while the session timeout is set for 2 hours. When I retrieve the data from the database is it possible to check with the IIS server if the found SessionID in the database is still valid for IIS?

        In Word you can only store 2 bytes. That is why I use Writer.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Obviously you can assume any session over two hours is not valid. A common practice I've noticed for this situation is to use a bit of AJAX to capture the browser events, whether an actual close or just navigating away from your site, and update the database to logout the user.


        only two letters away from being an asset

        1 Reply Last reply
        0
        • M Mike Ellison

          Does this CP article give you any ideas? ASP.NET HttpModule for handling session end with StateServer[^]

          www.MishaInTheCloud.com

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          thank you. this is helping me investigating further on

          In Word you can only store 2 bytes. That is why I use Writer.

          1 Reply Last reply
          0
          • H Herman T Instance

            Well.. this is not the simplle check if Session == null. In a global.asax file I log in a table the sessionID of a user. In the Session_End i add to that logline the date the session expired. well that works! But if a user chooses to close the browser in stead of logging out of an application....The additional logline with date session expiration is not saved. In an overview page I see that according to the database some sessions are days old while the session timeout is set for 2 hours. When I retrieve the data from the database is it possible to check with the IIS server if the found SessionID in the database is still valid for IIS?

            In Word you can only store 2 bytes. That is why I use Writer.

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            digimanus wrote:

            When I retrieve the data from the database is it possible to check with the IIS server if the found SessionID in the database is still valid for IIS?

            No. You can't get this. Two things you can try, 1 - Handle browsers close event using JS and do AJAX call to update the database. This method is less reliable as JS can be manipulated from client side. 2 - Write a DB job which executes on specific intervals, check the validity of records and updates the records that are inactive for long time. For this to work, you may need to keep the last request time as well. :)

            Navaneeth How to use google | Ask smart questions

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups