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

delayed session creation

P: n/a
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no cookies set). My pages will know that is Session = null then Session has not been created and they should not rely on it.

But at the moment user puts something into shopping cart i want to trigger session creation (set the cookies) and from no own that user will have regular session.

Is it doable with .NET Session or i will have to create my own Session object?
Thanks
George.
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi George,

Session is always there. Think of it as a box. It doesn't have anything IN
it until you PUT something in it. In addition, Session cookies are not saved
as a file on the client machine. They exist (in memory) only for the
lifetime of the client Session on your web site. They expire immediately.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"George" <no****@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no cookies
set). My pages will know that is Session = null then Session has not been
created and they should not rely on it.

But at the moment user puts something into shopping cart i want to trigger
session creation (set the cookies) and from no own that user will have
regular session.

Is it doable with .NET Session or i will have to create my own Session
object?
Thanks
George.
Nov 19 '05 #2

P: n/a
You misunderstood me,
I am very well aware how session works.

I do not want it to be created since it eats memory in my server and any malicious code hitting my box 1000 times a second will bring it down because my memory will be full of empty Sessions (boxes as you said)

All i want is somehow postpone the Session creation untill i need it( basically user want to put something into shopping cart).

All is needed is that ASP did not create session automaticly and sent the cookie back to the computer.
So the question is how can i do it with ASP.NET

PS: I always can have my custom Session object created and have on every page EnableSessionState = false. But i would rather use Session from ASP.NET

George.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message news:Ox**************@TK2MSFTNGP15.phx.gbl...
Hi George,

Session is always there. Think of it as a box. It doesn't have anything IN
it until you PUT something in it. In addition, Session cookies are not saved
as a file on the client machine. They exist (in memory) only for the
lifetime of the client Session on your web site. They expire immediately.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"George" <no****@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no cookies
set). My pages will know that is Session = null then Session has not been
created and they should not rely on it.

But at the moment user puts something into shopping cart i want to trigger
session creation (set the cookies) and from no own that user will have
regular session.

Is it doable with .NET Session or i will have to create my own Session
object?
Thanks
George.
Nov 19 '05 #3

P: n/a
this is not builtin. you need to write your own, or as a hack, on end request call session.abandon(), whenever you don't want to keep the session (just put a keep flag in the session). this will keep the memory footprint down.

but if you are doing a true shopping cart app, i would not use inproc sessions (too easy to the lose cart). i'd use a database and allow the cart to survive for days.


-- bruce (sqlwork.com)

"George" <no****@hotmail.com> wrote in message news:ui**************@TK2MSFTNGP14.phx.gbl...
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no cookies set). My pages will know that is Session = null then Session has not been created and they should not rely on it.

But at the moment user puts something into shopping cart i want to trigger session creation (set the cookies) and from no own that user will have regular session.

Is it doable with .NET Session or i will have to create my own Session object?
Thanks
George.
Nov 19 '05 #4

P: n/a
Hi,

Is this realy an issue? Do you have an idea of the memory sessions consume
that don't get used?

I haven't encountered a problem with this but I dont have 1000's of visitors.

Cheers,
Tom Pester
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no
cookies set). My pages will know that is Session = null then Session
has not been created and they should not rely on it.

But at the moment user puts something into shopping cart i want to
trigger session creation (set the cookies) and from no own that user
will have regular session.

Is it doable with .NET Session or i will have to create my own Session
object?

Thanks
George.

Nov 19 '05 #5

P: n/a
re:
PS: I always can have my custom Session object created
and have on every page EnableSessionState = false.


You answered your own question.

Disable SessionState on all the initial pages,
and enable SessionState at the point you want to.

You could also have an entry point in an application which
uses cookieless mode, and redirect to a cookie-enabled
application when you need it.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espanol
Ven, y hablemos de ASP.NET...
======================

"George" <no****@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
You misunderstood me,
I am very well aware how session works.

I do not want it to be created since it eats memory in my server and any malicious code
hitting my box 1000 times a second will bring it down because my memory will be full of
empty Sessions (boxes as you said)

All i want is somehow postpone the Session creation untill i need it( basically user want
to put something into shopping cart).

All is needed is that ASP did not create session automaticly and sent the cookie back to
the computer.
So the question is how can i do it with ASP.NET

PS: I always can have my custom Session object created and have on every page
EnableSessionState = false. But i would rather use Session from ASP.NET

George.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Ox**************@TK2MSFTNGP15.phx.gbl...
Hi George,

Session is always there. Think of it as a box. It doesn't have anything IN
it until you PUT something in it. In addition, Session cookies are not saved
as a file on the client machine. They exist (in memory) only for the
lifetime of the client Session on your web site. They expire immediately.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"George" <no****@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
Hi, Is it possible to delay session creation in ASP.NET

I want the user to browse my site without any session created (no cookies
set). My pages will know that is Session = null then Session has not been
created and they should not rely on it.

But at the moment user puts something into shopping cart i want to trigger
session creation (set the cookies) and from no own that user will have
regular session.

Is it doable with .NET Session or i will have to create my own Session
object?
Thanks
George.

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.