Tarasov
Tarasov

Reputation: 3685

How I can use a Session for a long time in my ASP.NET Application

I have a ASP.NET Application where I use Sessions. In this Session I get the language for Example.

Example:

Session["language"] = language; 

And in a other Area in my Code I use then...

language = Session["language"].toString();

It works fine but the user had open the Browser about a feu Hours in the Background with the Application then the Session don't work :(

Why it doesn't work and how I can solve this Problem.

Upvotes: 1

Views: 2096

Answers (2)

Asif Mushtaq
Asif Mushtaq

Reputation: 13150

You have two options either to use cookies or to increase session timeout setting.

You can increase the session timeout by increasing timeout in the web.config.

<configuration>
  <system.web>
  ...
   <sessionState timeout="90" />
  ...
 </system.web>
</configuration>

In my opinion using cookies is a better approach.

Beginners Guide To ASP NET Cookies

Upvotes: 2

platon
platon

Reputation: 5340

I would suggest that you save the value in a cookie.

Upvotes: 2

Related Questions