By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,542 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

Session[]

P: n/a
Do we have any access to the Session[] object from a different Session? The
idea is to save Session[] of a current user and then if he logs in again
then return the Session back. It's not a problem to store, there is only one
complicated object in this Session[], but to get it on SessionStart to make
a copy this is a problem.

Maybe using Application[] or whatever? Or this data is divided and
inaccessible anyway?

Just D.
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Just D. wrote:
Do we have any access to the Session[] object from a different Session? The
idea is to save Session[] of a current user and then if he logs in again
then return the Session back. It's not a problem to store, there is only one
complicated object in this Session[], but to get it on SessionStart to make
a copy this is a problem.

The session configuration element in web.config has a timeout attribute
which controls how long a session is considered valid. The session
timeout is a sliding value; on each request the timeout period is set to
the current time plus the timeout value.
If you need the session to be valid "forever", like session at
Amazon.com or similar, you should use SQL Server Mode. In SQL Server
Mode the session data is kept in the database.

For good coverage of session state in ASP.NET read Rob Howards MSDN
article on the topic
http://msdn.microsoft.com/library/de...sp12282000.asp

ASP.NET 2.0, which is released later this year, has a Profile API. This
API lets you define profile data which is automatically persisted for
both authenticated and anonymous users between visits to a web site.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 19 '05 #2

P: n/a
Thanks for the article, it's very interesting.

I know about the session timeout. The problem is little bit different. I
don't need cookies. The idea is if the client wants for some reason to use
another machine and uses his login then I need to "transfer" his session to
this new machine, i.e. copy the information stored in some
Sesson["SomeObject"] to another session and then finally start this session.
The previous one should be eliminated at the same time. If the timeout
occured then the Session[] should be serialized and stored on the database
to restore again whenever the client needs that. That's why I need to know
if it's possible and how if yes to copy data from the previous session to a
new one.

Just D.

"Anders Norås" <an**********@objectware.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Just D. wrote:
Do we have any access to the Session[] object from a different Session?
The idea is to save Session[] of a current user and then if he logs in
again then return the Session back. It's not a problem to store, there is
only one complicated object in this Session[], but to get it on
SessionStart to make a copy this is a problem.

The session configuration element in web.config has a timeout attribute
which controls how long a session is considered valid. The session timeout
is a sliding value; on each request the timeout period is set to the
current time plus the timeout value.
If you need the session to be valid "forever", like session at Amazon.com
or similar, you should use SQL Server Mode. In SQL Server Mode the session
data is kept in the database.

For good coverage of session state in ASP.NET read Rob Howards MSDN
article on the topic
http://msdn.microsoft.com/library/de...sp12282000.asp

ASP.NET 2.0, which is released later this year, has a Profile API. This
API lets you define profile data which is automatically persisted for both
authenticated and anonymous users between visits to a web site.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/

Nov 19 '05 #3

P: n/a
I don't have the solution to your problem, but the normal approach would be
to persist your users' data in a database between sessions, and load them up
each time the user logs in. So you would have a different *session* each
time. I hope that makes sence.

Michal

--
Michal Boleslav Mechura
va******@hotmail.com

"Just D." <no@spam.please> wrote in message
news:iL8Kd.978$Jt.294@fed1read02...
Thanks for the article, it's very interesting.

I know about the session timeout. The problem is little bit different. I
don't need cookies. The idea is if the client wants for some reason to use
another machine and uses his login then I need to "transfer" his session
to this new machine, i.e. copy the information stored in some
Sesson["SomeObject"] to another session and then finally start this
session. The previous one should be eliminated at the same time. If the
timeout occured then the Session[] should be serialized and stored on the
database to restore again whenever the client needs that. That's why I
need to know if it's possible and how if yes to copy data from the
previous session to a new one.

Just D.

"Anders Norås" <an**********@objectware.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Just D. wrote:
Do we have any access to the Session[] object from a different Session?
The idea is to save Session[] of a current user and then if he logs in
again then return the Session back. It's not a problem to store, there
is only one complicated object in this Session[], but to get it on
SessionStart to make a copy this is a problem.

The session configuration element in web.config has a timeout attribute
which controls how long a session is considered valid. The session
timeout is a sliding value; on each request the timeout period is set to
the current time plus the timeout value.
If you need the session to be valid "forever", like session at Amazon.com
or similar, you should use SQL Server Mode. In SQL Server Mode the
session data is kept in the database.

For good coverage of session state in ASP.NET read Rob Howards MSDN
article on the topic
http://msdn.microsoft.com/library/de...sp12282000.asp

ASP.NET 2.0, which is released later this year, has a Profile API. This
API lets you define profile data which is automatically persisted for
both authenticated and anonymous users between visits to a web site.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/


Nov 19 '05 #4

P: n/a
Yes, it was the original idea. The problem is deeper. Each session has some
timeout. IF the user closes his browser then I can understand that and send
the command to close the session, serialize data, etc. But if the user loses
the connection then the server size knows nothing about it, so the data is
not serialized and not saved, it remains in Session until the timeout when I
can serialize and save it. Imagine also that - the user goes to a different
computer and opens another session, he wants to get the data that have been
in work before, but the data is not saved, it's still in the previous
session.

As a possible solution is just to serialize data every time and save on the
database. So, each time when the Session object updates we save data. We're
good, the server is dead. Imagine 500 clients for example and how XML
serialization increases the object size. I don't like to serialize the
session object every time it changes.

So the reasonable would be just to catch the previous session in memory and
copy all objects, actually only one big, from previous session to a new one.

I think I could use Application[] instead od Session[], it will work with
some modifications, slower, but more or less acceptable. But the question
about Session still remains alive. This way is more elegant. Maybe it's not
very bad idea to store the reference to this object in Application as
well... I will see how it works.

Just D.

"Michal Boleslav Mechura" <va******@hotmail.com> wrote in message
news:11***************@ns1-ext.dcu.ie...
I don't have the solution to your problem, but the normal approach would be
to persist your users' data in a database between sessions, and load them
up each time the user logs in. So you would have a different *session* each
time. I hope that makes sence.

Michal

--
Michal Boleslav Mechura
va******@hotmail.com

"Just D." <no@spam.please> wrote in message
news:iL8Kd.978$Jt.294@fed1read02...
Thanks for the article, it's very interesting.

I know about the session timeout. The problem is little bit different. I
don't need cookies. The idea is if the client wants for some reason to
use another machine and uses his login then I need to "transfer" his
session to this new machine, i.e. copy the information stored in some
Sesson["SomeObject"] to another session and then finally start this
session. The previous one should be eliminated at the same time. If the
timeout occured then the Session[] should be serialized and stored on the
database to restore again whenever the client needs that. That's why I
need to know if it's possible and how if yes to copy data from the
previous session to a new one.

Just D.

"Anders Norås" <an**********@objectware.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Just D. wrote:
Do we have any access to the Session[] object from a different Session?
The idea is to save Session[] of a current user and then if he logs in
again then return the Session back. It's not a problem to store, there
is only one complicated object in this Session[], but to get it on
SessionStart to make a copy this is a problem.
The session configuration element in web.config has a timeout attribute
which controls how long a session is considered valid. The session
timeout is a sliding value; on each request the timeout period is set to
the current time plus the timeout value.
If you need the session to be valid "forever", like session at
Amazon.com or similar, you should use SQL Server Mode. In SQL Server
Mode the session data is kept in the database.

For good coverage of session state in ASP.NET read Rob Howards MSDN
article on the topic
http://msdn.microsoft.com/library/de...sp12282000.asp

ASP.NET 2.0, which is released later this year, has a Profile API. This
API lets you define profile data which is automatically persisted for
both authenticated and anonymous users between visits to a web site.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/



Nov 19 '05 #5

P: n/a
one session does not have access to another. but you have several options.
you could serialze out the session data that applies to a user, and store it
in a db rather than session. if you want in memeory, store references to the
user session objects in a static hashtable, application object, or
application cache.

-- bruce (sqlwork.com)
"Just D." <no@spam.please> wrote in message
news:iL8Kd.978$Jt.294@fed1read02...
| Thanks for the article, it's very interesting.
|
| I know about the session timeout. The problem is little bit different. I
| don't need cookies. The idea is if the client wants for some reason to use
| another machine and uses his login then I need to "transfer" his session
to
| this new machine, i.e. copy the information stored in some
| Sesson["SomeObject"] to another session and then finally start this
session.
| The previous one should be eliminated at the same time. If the timeout
| occured then the Session[] should be serialized and stored on the database
| to restore again whenever the client needs that. That's why I need to know
| if it's possible and how if yes to copy data from the previous session to
a
| new one.
|
| Just D.
|
| "Anders Norås" <an**********@objectware.no> wrote in message
| news:%2****************@tk2msftngp13.phx.gbl...
| > Just D. wrote:
| >> Do we have any access to the Session[] object from a different Session?
| >> The idea is to save Session[] of a current user and then if he logs in
| >> again then return the Session back. It's not a problem to store, there
is
| >> only one complicated object in this Session[], but to get it on
| >> SessionStart to make a copy this is a problem.
| > The session configuration element in web.config has a timeout attribute
| > which controls how long a session is considered valid. The session
timeout
| > is a sliding value; on each request the timeout period is set to the
| > current time plus the timeout value.
| > If you need the session to be valid "forever", like session at
Amazon.com
| > or similar, you should use SQL Server Mode. In SQL Server Mode the
session
| > data is kept in the database.
| >
| > For good coverage of session state in ASP.NET read Rob Howards MSDN
| > article on the topic
| >
http://msdn.microsoft.com/library/de...sp12282000.asp
| >
| > ASP.NET 2.0, which is released later this year, has a Profile API. This
| > API lets you define profile data which is automatically persisted for
both
| > authenticated and anonymous users between visits to a web site.
| >
| > Anders Norås
| > http://dotnetjunkies.com/weblog/anoras/
|
|
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.