473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Session Variable Alternative

I have a few questions for ASP.net in C#. I am using a session variable to
pass the user name from page to page. After a while, the session variable
times out. Is there a way around the time out? Also, what would be a better
way to keep track of the user's name. Will using forms authentication work
better? Right now it is just a debug application, so I didn't turn on Forms
Authentication. I've also never used it. So I don't know what it can
handle, etc....

Thanks -

Drew
Nov 18 '05 #1
5 1561
The only way to avoid loss of data on a timeout is to use a cookie and store
your values in there, as cookies can persist between sessions. You can
lengthen the timeout of a session in your web.config.

Have a read of this to learn a bit more about sessions.....
http://msdn.microsoft.com/library/de...us/dnaspnet/ht
ml/asp12282000.asp

It doesn't really matter what authentication method you use, if you lose
your session via timeout for example the authentication credentials will go
too.

Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Drew" <Dr**@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
I have a few questions for ASP.net in C#. I am using a session variable to pass the user name from page to page. After a while, the session variable
times out. Is there a way around the time out? Also, what would be a better way to keep track of the user's name. Will using forms authentication work better? Right now it is just a debug application, so I didn't turn on Forms Authentication. I've also never used it. So I don't know what it can
handle, etc....

Thanks -

Drew

Nov 18 '05 #2
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:OT****************@TK2MSFTNGP10.phx.gbl...
The only way to avoid loss of data on a timeout is to use a cookie and store your values in there, as cookies can persist between sessions.


Rubbish! If you *really* want to persists data between sessions, store it in
a server-side database.
Nov 18 '05 #3
You can use a StateServer to store session data in RAM on another box (or
another process on the same box.)
This won't help witha timeout though. (It will save you when the aspnet
process recycles itself.)

You can also persist the session to a database if you want. SQL Server only
for 1.1, should be extensible to any DB for 2.0. This will keep the data as
long as you like.

I use forms authentication and store the user name in the Identity object
which is available on every request becasue I keep it in session and pull it
out in Global.asax - AcquireRequest State.
--
Joe Fallon

"Drew" <Dr**@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
I have a few questions for ASP.net in C#. I am using a session variable to
pass the user name from page to page. After a while, the session variable
times out. Is there a way around the time out? Also, what would be a
better
way to keep track of the user's name. Will using forms authentication
work
better? Right now it is just a debug application, so I didn't turn on
Forms
Authentication. I've also never used it. So I don't know what it can
handle, etc....

Thanks -

Drew

Nov 18 '05 #4
You are correct that you can obviously store data in a server side database,
or a text file even - but it implies that you have information about your
user that identifies them as each new session begins - and in fact a
database to actually hold the values in. Drew could of course also use the
application object byt that itself does not offer persistence between
applications recycling.

If you read the thread - Drew was asking how to persist the username between
sessions in case of timeout. If he is getting the user name at login from a
server side store why would he need to persist it between timeouts at all?
Perhaps I should have said the "easiest way" to persist was with a cookie,
rather than the "only way", as any server side storage between sessions
implies requiring knowledge about the remote user it is by far the most
straightforward approach.

Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:ub**************@TK2MSFTNGP12.phx.gbl...
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:OT****************@TK2MSFTNGP10.phx.gbl...
The only way to avoid loss of data on a timeout is to use a cookie and store
your values in there, as cookies can persist between sessions.


Rubbish! If you *really* want to persists data between sessions, store it

in a server-side database.

Nov 18 '05 #5
Thanks guys - I will try this on Monday and get back with you.

"Joe Fallon" wrote:
You can use a StateServer to store session data in RAM on another box (or
another process on the same box.)
This won't help witha timeout though. (It will save you when the aspnet
process recycles itself.)

You can also persist the session to a database if you want. SQL Server only
for 1.1, should be extensible to any DB for 2.0. This will keep the data as
long as you like.

I use forms authentication and store the user name in the Identity object
which is available on every request becasue I keep it in session and pull it
out in Global.asax - AcquireRequest State.
--
Joe Fallon

"Drew" <Dr**@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
I have a few questions for ASP.net in C#. I am using a session variable to
pass the user name from page to page. After a while, the session variable
times out. Is there a way around the time out? Also, what would be a
better
way to keep track of the user's name. Will using forms authentication
work
better? Right now it is just a debug application, so I didn't turn on
Forms
Authentication. I've also never used it. So I don't know what it can
handle, etc....

Thanks -

Drew


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robin Edgar Hansen | last post by:
Hi! I'd like to store an object in a session variable and thus keep it 'alive' for the entire session. More precisely I wanted to do this (possibly in Application_OnStart()): import telnetlib...
1
by: gfuller | last post by:
- We have 2 aspx pages in a .NET project. The first sets a session variable and has a button that when clicked performs a 'redirect' to the second page which then reads the session variable. ...
3
by: Philip Tepedino | last post by:
I'm having an odd problem. My website's session state is getting shared between users! This problem only happens when a user tries to access the site from inside our corporate LAN. The user,...
2
by: sb | last post by:
As the session variable are not recommended, i search for an alternative to store my classe that i use and that i store in that session variable. is that the context that is the alternative? ...
4
by: Nick Gilbert | last post by:
Hi, Is it possible to access the Session of an arbitary user from an aspx page? On an e-commerce site, I am notified of payment success via a callback from the payment server to an ASPX page...
4
by: carthegenian | last post by:
I have created a session variable.... and i have to write code to check for this session for each ASP webpage in my website....Is there a alternative...?? I do not want to repeat the same code...
2
by: mark4asp | last post by:
Can I cache a DataTable (or alternative GridView Datasource) in a Session object? .... and does the following scenario present itself as an occaison when I could get away with doing so? In an...
3
by: Sylvie | last post by:
When redirecting a page, For example CASE 1; Response.Redirect("Page.aspx?Paramval=123"); in Page.aspx
3
Vini171285
by: Vini171285 | last post by:
Hi, In my project, i am saving all details in Session variables to retain them between pages.. but the problem is,when i save a single value,it is stored in session variable,but suppose i try to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.