Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:55:38+00:00 2026-06-09T17:55:38+00:00

I am wondering what is the best (e.g. most efficient, commonly accepted, industry standard)

  • 0

I am wondering what is the best (e.g. most efficient, commonly accepted, industry standard) way to deal with the potential expiration of a session when you are regularly using the values stored in it in your code.

For example, I am often using (in C#) lines similar to the following:

Guid personGuid = (Guid)Session[SSPersonGuid];

I am checking in Page_Load whether the values are null and dealing accordingly, but the session might expire while the person is on the page, in which case when they click a button on the page, and we need to use something like the above, there will be a NullReferenceException.

Is the best way to handle this just to check for null before each usage like this:

if (Session[SSPersonGuid] == null) {...}

Or is there some kind of special thing I don’t know about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:55:40+00:00Added an answer on June 9, 2026 at 5:55 pm

    What is the best (e.g. most efficient, commonly accepted, industry
    standard) way to deal with the potential expiration of a session?

    The best would be that they dont expire by setting up a Out-Of-Process session state server or out-of-process SQL Server.

    Also you may detect it in the The Session_OnEnd Event

    EDIT:

    Something Jeff Atwood says here corresponds with Scotts answer: http://www.codinghorror.com/blog/2008/04/your-session-has-timed-out.html

    I am inundated with session timeout messages every day from a variety
    of sources, but I’ve never once seen a session expiration message from
    gmail, for example. Here’s what I suggest:

    1. Create a background JavaScript process in the browser that sends
      regular heartbeats to the server. Regenerate a new cookie with timed
      expiration, say, every 5 or 10 minutes.

    2. If you’re worried about
      session hijacking — and you really should be — use a HTTPS protected
      connection. This is an absolute no-brainer for financial institutions
      of any kind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering what the best and most efficient way to write up the following
I am wondering what the best / most efficient / common way is to
I am just wondering what's the most efficient way to export mysql data to
I'm wondering if this is the most elegant and efficient way of doing this?
I'm wondering what is the most efficient way to obtain autocomplete results from multiple
I was wondering if you could tell me what the most efficient way to
Basically, wondering what the best / most python-y way of doing this is; class
I was wondering what would be the most efficient way to make a map
I am wondering what the most efficient way is to make a CALayer with
Just wondering, what is the most reliable/best way to attach GDB to process ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.