• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

how to keep the session variable alive until the user close the browser?

Hai,
  I had developed a web application in C#ASP.net 1.1.I have set application session time out as 45 min. in web.config.
I had used windows authentication mode in web config.
  In my application its has several pages and the user can login from any page of my application.I had passed the username between the pages using session variable.
  My problem is, when a user working in my apllication in different tabs of same browser and the user works continously in one tab and another tabs are keep remain and the session variables are expired in another tabs.and the user clicks the login page it shows that "YOU ARE ALREADY SIGNED IN"?
   how to prevent this type of problem?
  And I also needed that, can we use different session between the browser tabs.Is it possible?

Plz give me a solution to solve this kind of problem
       
0
Nissiinfotech
Asked:
Nissiinfotech
  • 6
  • 5
1 Solution
 
swapneel_d14Commented:
When you see "YOU ARE ALREADY SIGNED IN"? that means session vaibales are not expired and it is active.. isnt it?

You can use page level session varibales/values.
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
Plz send some smple codes to solve this problem
0
 
swapneel_d14Commented:
just do          Session["Pagenamecheckin"] = 1; for your page and do seesion checking for that page.

or elaborate problem details so we could assist you
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
 I can login my application from different pages of my application.
 In login page load it checks the Session["username"]==null means it will show login page else
it shows "YOU ARE ALREADY SIGNED IN".
  It seems that the Session["Pagenamecheckin"] is always 1 and how it keep the session variables alive in another tabs of the same browser

Plz send some more codes to solve this problem
0
 
swapneel_d14Commented:
Session object is created on combination of User and Application  and not for differnt tabs of same application.  Session["Pagenamecheckin"]  will be active for your application on differnt tabs.  

check out this Link if you want to create session varibales for each page.
http://www.codeproject.com/KB/aspnet/session_facade.aspx

Do you to ask your user to login on each and every page (tabls) then Create Pagespecific  session varaibles

On Page A
check Session["Acheckin"]   == null then Login Page and  Display Page A  then  check Session["Acheckin"]   =1
On Page B
check Session["Bcheckin"]   == null then Login Page and Display Page A then check Session["Bcheckin"]   = 1

i hope this helps.





0
 
NissiinfotechAuthor Commented:
Hai,
   Thanks for your reply

   to prevent this type of problem while given it checks the session expired time and it check the session is available or not.
  If it is yes and extended the session time and it is not and it expired  
0
 
swapneel_d14Commented:
So you are using  my 3rd comment as solution.. isn't it?


Was this comment helpful? YesNo
swapneel_d14:
Session object is created on combination of User and Application  and not for differnt tabs of same application.  Session["Pagenamecheckin"]  will be active for your application on differnt tabs.  

check out this Link if you want to create session varibales for each page.
http://www.codeproject.com/KB/aspnet/session_facade.aspx
0
 
NissiinfotechAuthor Commented:
Hai,
  Yes you are correct, but in case of above problem you should check the session time out in all pages which gives that the session is available or not.  
  You solution is correct It will ablicable for a small application and for a large application you can check out
that session is available or not.
0
 
swapneel_d14Commented:
I don't know what you mean by session time out in all pages.,....
Session time out is on application level  and not on a page level.
0
 
NissiinfotechAuthor Commented:
Hai,
   Session state is available after the HttpApplication.AcquireRequestState event is called. For details, see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhandlingpublicevents.asp
  You can check with SessionId over there.

0
 
swapneel_d14Commented:
OK. Cheers.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now