delayed session creation

Discussion in 'ASP .Net' started by George, Jun 17, 2005.

  1. George

    George Guest

    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.
     
    George, Jun 17, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:uis8$...
    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.
     
    Kevin Spencer, Jun 17, 2005
    #2
    1. Advertising

  3. George

    George Guest

    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" <> wrote in message news:OxA$...
    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" <> wrote in message
    news:uis8$...
    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.
     
    George, Jun 17, 2005
    #3
  4. George

    Bruce Barker Guest

    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" <> wrote in message news:uis8$...
    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.
     
    Bruce Barker, Jun 17, 2005
    #4
  5. George

    Guest

    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.
     
    , Jun 18, 2005
    #5
  6. 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" <> wrote in message
    news:...
    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" <> wrote in message
    news:OxA$...
    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" <> wrote in message
    news:uis8$...
    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.
     
    Juan T. Llibre, Jun 18, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guru Prasad

    unloading assemblies - delayed ?

    Guru Prasad, Jul 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    424
    Guru Prasad
    Jul 21, 2003
  2. e

    delayed page requests

    e, Oct 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    318
  3. Delayed key-event ?

    , Aug 15, 2003, in forum: Java
    Replies:
    3
    Views:
    321
    S. Balk
    Aug 15, 2003
  4. matt
    Replies:
    1
    Views:
    409
  5. matt
    Replies:
    8
    Views:
    231
    Mauricio Fernández
    Jun 19, 2004
Loading...

Share This Page