Showing posts with label userid. Show all posts
Showing posts with label userid. Show all posts

Monday, March 26, 2012

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable'Can you write out the value of your session id to make sure it is not
changing between postbacks?
"Vlady" wrote:

> The scenario is the following: from the login page I set a session variabl
e
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, i
f
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill no
w!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type
,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable'

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable??Can you write out the value of your session id to make sure it is not
changing between postbacks?

"Vlady" wrote:

> The scenario is the following: from the login page I set a session variable
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, if
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill now!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable??

Saturday, March 24, 2012

session variable timeout?

I have a userID stored in a session variable. I use this ID to track who entered what.
My problem is that this ID seems to get lost every now and then,resetting to 0. How can I get my server to store the userID in asession for a set duration after the last refresh?
Hi,
What is the timeout you have specified for the session in the web.config. Try increasing the timeout.
Thanks.
There is no information on timeouts in my webconfig.
Where can I find information on how to add this?

Thank you/

Hi,
Try to locate the following in your web.config

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/>
You need to change it in the above (timeout).
Thanks.


The timeout is not with my database.
The timeout is because the userID stored in the session is being lost.How do I increase the time that a session variable is stored?

Sorry, my mistake. I thought he was setting the database timeout because I saw the connection string.
I'll try it and let you know how it goes.
Thank you.

What ranganh said is correct
The session variable will persist until the time out specified in the web.config is reached
or you cleared it in the code by removing the variable from session or by using
Session.Clear() or Session.Abandon() methods.

Session variables

Hi,
Basically I see two options:
1- Use application variables, with a Hashtable and the userID is the key.
2- Use a class with a static Hashtable or similar struct. it will be global
to the application therefore will not expire with the section.
Please note that both solutions assume that you are doing this for
registered users, if you allow anonymous users and treat each session as a
different user you have to do something else.
Cheers,
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Bonj" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:B3D56FFC-CC10-495D-9C62-450DED7D33B2@dotnet.itags.org.microsoft.com...
> I see Session variables time out after 20 minutes (or whatever number of
minutes you define).
> I want to have some variables that won't time out, but they only occupy
very small amounts of data, say 10-20 bytes per user, so I think it won't
too much of a performance impact to store it in the web server's memory.
Would having hash tables as global variables using the SessionID as key work
OK? Global variables and SessionIDs don't time out do they?"Bonj" <anonymous@.discussions.microsoft.com> wrote in message news:B3D56FFC-CC10-495D-9C62-
450DED7D33B2@.microsoft.com...
> I see Session variables time out after 20 minutes (or whatever number of m
inutes you define).
> I want to have some variables that won't time out, but they only occupy very small
amounts of data, say 10-20 bytes per user, so I
think it won't too much of a performance impact to store it in the web serve
r's memory. Would having hash tables as global variables
using the SessionID as key work OK? Global variables and SessionIDs don't ti
me out do they?
It's not the session *variables* that time out, it's the *session* that will
be removed (along with all stored values) after the user has done
nothing (=no new page request) for 20 minutes.
How long do you want to keep this data? Could you store it in
a database?
Hans Kesting
All Session variables expires after 20 (or x minutes you choose) whatever
type they have, also the corresponding SessionID of the expired Session. Use
Application variables to store common variables.
Horatiu Ripa
"Bonj" <anonymous@.discussions.microsoft.com> wrote in message
news:B3D56FFC-CC10-495D-9C62-450DED7D33B2@.microsoft.com...
> I see Session variables time out after 20 minutes (or whatever number of
minutes you define).
> I want to have some variables that won't time out, but they only occupy
very small amounts of data, say 10-20 bytes per user, so I think it won't
too much of a performance impact to store it in the web server's memory.
Would having hash tables as global variables using the SessionID as key work
OK? Global variables and SessionIDs don't time out do they?
You could also look at storing this data in an encrypted cookie. Then you
can set the timeout to whatever you wish with no server overhead.
-mike
MVP
"Bonj" <anonymous@.discussions.microsoft.com> wrote in message
news:B3D56FFC-CC10-495D-9C62-450DED7D33B2@.microsoft.com...
>I see Session variables time out after 20 minutes (or whatever number of
>minutes you define).
> I want to have some variables that won't time out, but they only occupy
> very small amounts of data, say 10-20 bytes per user, so I think it won't
> too much of a performance impact to store it in the web server's memory.
> Would having hash tables as global variables using the SessionID as key
> work OK? Global variables and SessionIDs don't time out do they?