0

I don't know if this is possible.
When I set sesstion variable:

Session["name"] = "name";

Can I set somehow time out for this variable (specific to this one)?
In web config timeout can be set to 20 minutes but I want this session variable to stay a live whole day.
Is this possible?

1110
  • 7,829
  • 55
  • 176
  • 334
  • You going to have to consider alternatives to session for storing variables as, unless the user refreshes the page, the maximum 'holding time' for a session variable is 20 mins. See this following link for a better understanding of session variables: ww.w3schools.com/asp/asp_sessions.asp –  Sep 14 '12 at 08:57
  • You can change the 'maximum' though in the web.config or on IIS once your application is published. – chead23 Sep 14 '12 at 09:02

2 Answers2

1

I don't think it is possible for individual Session variables but I think you could probably achieve the same results using a cookie

Response.Cookies("name").Value = name
Response.Cookies("name").Expires = DateTime.Now.AddDays(1)
chead23
  • 1,859
  • 11
  • 12
1

With Session no, because session is only for the time that the user is online and being aware of the timeout specified in the web.config. You can extend the timeout, but even that can fail, for example if the application pool is restarted.

The best way to do this is or sql, variable that you save in the server or a cookie, depends of the behavior that you want to apply.

DadViegas
  • 2,263
  • 16
  • 12