session variable gets lost

Hi! I have a session variable, and I set the Session.timeout=120; but after a while (not even 30 mins )it got lost and had errors cause of that in the app_code, where I have a function that takes as parameter the session variable value. Thank for any advice.

0
James25
2/4/2008 9:20:36 PM
asp.net.state-management 8807 articles. 0 followers. Follow

5 Replies
860 Views

Similar Articles

[PageSpeed] 25

Firstly make sure you are never overwriting the session variable.

Another thing would be if the web server is low on resources it may drop some session items. 

0
jimmy
2/4/2008 9:25:56 PM

Make sure in the web.config file the session timeout is set properly

     <sessionState timeout="120"/>

Check below link for more info

http://msdn2.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout.aspx

HC
 


Haissam Abdul Malak
MCAD.NET
| Blog |
0
Haissam
2/4/2008 9:29:22 PM

Hi! I put this in the web config:

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

stateNetworkTimeout="10"

sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"

sqlCommandTimeout="30"

customProvider=""

cookieless="UseCookies"

cookieName="ASP.NET_SessionId"

timeout="60"

allowCustomSqlDatabase="false"

partitionResolverType=""

useHostingIdentity="true">

 

Now, if I set the timeout= "1" the session ends after 1 min, but if I set the timeout= 60 it ends at 20 mins. It seems like if I set the timeout less than 20 min it works, but If I set it to more than 20 mins it doesnt work. Any help appreciated.

0
James25
2/6/2008 12:10:28 AM

I just tested the session timing again and it exipred after 10 mins, maybe less, but When I checked after 10 min it was gone.

0
James25
2/6/2008 12:17:03 AM

in this situation where  you needs to store many values ,and each one has different period to stay in memory

you need to  use the cache instead ,

by using cache, you can specify the  period of time that the value must stay in there before destroyed,

the following link will be helpful for you:

http://msdn2.microsoft.com/en-us/library/ms972379.aspx
 

 Hope it helps
 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
2/6/2008 10:47:00 AM
Reply:

Similar Artilces:

Session Variables getting lost
Hi I have a Parent Page called Parent.aspx in which i have a Grid View which has a column in which button is placed from which i am opening a Pop Up Window(Page) named Child.aspx. Before opening th pop up i assigning a DataTable to a Session variable so that i can access the DataTable in Child.aspx which can be accessed.Now I have created the 2nd DataTable in Parent.aspx for which the rows are added in the child.aspx page. The 2nd DataTable need to maintain all the rows which are added in child.aspx page. but unfortunately i am not getting  the DataTable from the Session .If i make...

After a looong night managed to change Session mode from inProc to SQLServer but still can't get the session variables to be saved
Hi,  I ran my Shopping Cart project and somehow everything worked fine(while in inProc), session variables were saved fine. I made some changes to my project and since then keep getting null session variables, no matter what I do. It took me the whole night to figure out how to turn to SQLServer mode,  marked custom classes as 'Serializable' with [Serializable] before the class definition but everything's in vain. Getting the same damned 'nulls' instead of the saved objects. private void Page_Load(object sender, System.EventArgs e)         {...

ColdFusion Session Variables Getting Lost
Name: Randy Email: randyatgetsetdotcom Product: Firefox Release Candidate Summary: ColdFusion Session Variables Getting Lost Comments: I am a ColdFusion Programmer and just downloaded Firefox 3.0. Twice in the last twenty four hours my ColdFusion session variables have suddenly disappeared. It is possible they timed out. They have a two hour limit set but typically they persist two hours from last use it is possible they are timing out two hours from their creation. Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9) Gecko/2008051202 Firefox/3.0 ...

Session variable value gets lost
I am using asp.net 3.0 with C#. My web application requires some values that is used across my User Controls. These values are pertaining to the login user name and User type. When each user is logged in I store that username and user type in a session variable and whenever i need to used it like in a query I just called the string variable that is assigned to the Session variable. My problem is sometimes my session object/ string variable loses its value and I am wondering is there another way of storing my User's credential so that the value will not be lost until the User closes his/h...

session variable gets lost when calling a class
 HiI have a wierd problem that I am really struggling with I have a session variable session("userid") that I use throughout a site with no problems I am using a class to upload a file , the class is called on the on_click event of a button when this class is called , the class works fine , does nothing unusual and does not use session variables , after the call to the class has done its thing the session("userid") is set to nothing ?Does anyone know why this might be happening ? thanks    How are you accessing the Session in the class? Make sure you are...

State management upon session variable changes
I noticed that whenever a session variable is changed...the application knows about it and suddenly restarts session. My question is does restart "ALL" sessions or only the active sessions for which the variables changed? Imagine a "multi-user" application all with different states and an administration panel that lets you change session variables.  In this case, my question has to do with the question that if Company X changes his session variables, will only Company X's sessions be reset or will all "sessions" be reset?  Hope that makes sense. ...

Session state keeps getting lost it seems....
I've had this problem for months it seems and I still haven't figured it out... I have a large, complex SQL-driven web application with 100 or so users. Every once in awhile users randomly get logged out and I think it's because the session is getting reset. I can't figure out why. I figured out one thing that was part of the problem. I was updating the system constantly, changing dozens of relatively large files at a time, and from what I read, if you do that too oftenASP will eventually run out of ram and reset itself, losing the session state. Apparently ASP doesn't get rid of the ...

Session variables vs. Session States
What is the difference and in what situations are they used. Thanks, Mattypee A session state (the state of your session) holds your session variables. If your session state expires (due to inactivity) then you lose your session variables...and any other info stored for that session. If you need to store USER specific information within a web app, then session variables are one(of several) ways to do it. MajorCatsMajorCats Is there any code that you could show that would give an example? Thanks, Mattypee example of what? reading and writing session variables? ...

Opinions on Viewstate vs. Session variable for state management on dataset
I came across many sample codes that using ViewState(myDataSet) and Session("myDataSet"). Which is a better way to use to keep the session around. What are the pros and cons? Anybody can share with your experience or thoughts? Thanks, teresa Take a loot at this article: State Management in Web Forms http://www.c-sharpcorner.com/Code/2004/Feb/StateManagementInWebForms.aspDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!...

Good news for those of you who get "Unable to make the session state request to the session state server." error..
Dear all,Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error: Server Error in '/cv2' Application.Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accep...

Last variables stored in Session get lost when redirecting to _target page.
 We have a session object that holds certain data - on our last panel of our panel wizard we ask two questions: checkbox :  Use pre-printed paper?radioBox:  Most recent test                    All past tests we save those two variables to our session like several other variables that we have saved. This then Redirects to a _target page that builds our report.  HOWEVER, alot of the time (AND NOT ALWAYS) these last two variables do not get populated to our session?  If I debug and...

Session State Variables across multi sessions
I am having an issue where I save my DataTable into a Session Variable:   Session["dtDMFile"] = dtDMFile; Different users can use the web form that I created. Once the data is loaded,I send the DataTable to the session variable. My problem is that when I go to reload the data in the table, it is taking the data from the last user who stored the DataTable instead of from the particular user on their browser. For instance, User 1 (machine 1) loads data with field contents of: field1  field2  field3 User 2 (machine 2), then loads data with field contents of: f...

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

getting a new session id and losing session variables
prb: I have two pages in my app - one on redirect and the other as a new window - that get a new session id from every other page in the app (they both get the same session id) and obviously the session state variables are lost and, therefore, the pages do not look like they should.  All pages are within the same domain and virtual directory. 1. a redirect; session variables are lost; session id is different from the previous page; if you click the BACK button you return to the previous page and the session id is the same as before and the session variables are as they should be2. ...

Web resources about - session variable gets lost - asp.net.state-management

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Staley: 'A lot of different variables...been a hard year'
... 41° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Staley: 'A lot of different variables...been ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 1/14/2016 11:23:58 PM