Question about Session_Start event

I have this code that runs in Session_Start event to update the last activity date for each user.
I thought that by putting it in Session_Start I will guarantee that when the user access the website this event will fire & updates his last activity date and if the user left the browser idle for more than 20 min when the session is supposed to timeout & he then re-access the site , the event will fire again as the session ended but this seems not to happen.
I have been testing this with IE7, I access the site, session start fires & I can see the activity date updated in the db, I leave the browser idle for more than 20 min then I refresh but the session_start doesn't fire again, only if I opened a new browser and accessed the site but refreshing the same tab seems not to let it fire again.

I don't know if I have explained my issue well but my main question is, is it correct that the session_start event only fires when opening new browser and doesn't fire when leaving the browser idle and then re-accessing the site again thru the same tab or opening a new tab?

Thanks in advance
LVL 3
JessyEzzyAsked:
Who is Participating?
 
RejojohnyConnect With a Mentor Commented:
>>is it correct that the session_start event only fires when opening new browser and doesn't fire when leaving the browser idle
no, it should have fired for the first case too .. are you sure your session is timing out?

Rejo
0
 
discon0Connect With a Mentor Commented:
Rejojohny is right, the event should fire.

Add this to your web.config file to make your session last 1 minute only to help you test this without waiting 20 minutes.

      ...
      <system.web>
            ...
            ...
            <sessionState timeout="1" />
      </system.web>
      ...
0
 
JessyEzzyAuthor Commented:
I tested it again and the session_start event fired after again but I realized that it does when you leave the whole browser idle what I was doing before is leaving the tab with the website am testing and working on other tabs. So this means that as long am working on other tabs the session won't timeout and I must leave the whole browser window idle and in that case it will fire when reaccessing the site?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
RejojohnyCommented:
>>So this means that as long am working on other tabs the session won't timeout and I must leave the whole browser window idle and in that case it will fire when reaccessing the site?
Yes, session only times out when there is no interaction with the server .. so if keep working on the screen for 20 minutes and there was no interaction with the server (no submits or postbacks), then the session will timeout

Rejo
0
 
JessyEzzyAuthor Commented:
Well thanks I thought that the session not shared across browser tabs.
0
 
RejojohnyCommented:
oh, you meant browser tabs .. sorry I mistook that for tabs within your application .. I am not sure about browser tabs in the latest version of IE, but session do get shared when you open a new window from a existing browser window .. so i assume that is the same behavior when you open a new tab within the same browser...

Thanks for the points ..

Rejo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.