Session[]

J

Just D.

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.
 
?

=?ISO-8859-1?Q?Anders_Nor=E5s?=

Just said:
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/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.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/
 
J

Just D.

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 said:
Just said:
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/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.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/
 
M

Michal Boleslav Mechura

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
(e-mail address removed)

Just D. said:
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 said:
Just said:
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/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.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/
 
J

Just D.

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 said:
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
(e-mail address removed)

Just D. said:
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 said:
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/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.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/
 
B

bruce barker

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)


| 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.
|
| | > 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/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.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/
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top