Session cleaning problem

Discussion in 'ASP General' started by Dan King, Oct 9, 2004.

  1. Dan King

    Dan King Guest

    At a summary page, I am trying to clean up Session.Contents so the user can
    go back to the main page and not retain any unnecessary info.
    I have entered this into my summary page, but it seems to only eliminate
    every other or every third entry. If I refresh the page about 0 times
    everything eventually clears out. Anyone know why it would do this?

    I don't want to use Session.Abandon because there are a few Session.Contents
    I want to retain, like usernams and passwords.

    <%
    ----snip----
    For Each objItem in Session.Contents
    Session.Contents.Remove objItem
    Next
    ----snip----
    %>

    Session.Contents are being added like this:

    <%
    ----snip----
    Session("uName") = uName 'put info into a session variable
    Session("uEmail") = uEmail 'put info into a session variable
    Session("uPass") = uPass 'put info into a session variable
    Session("uDomain") = uDomain 'put info into a session variable
    ----snip----
    %>

    Thanks


    --
    __o
    _-\<,
    (_)/(_)____
     
    Dan King, Oct 9, 2004
    #1
    1. Advertising

  2. Dan King

    Dan King Guest

    I found my answer.
    ---------
    arrSessionsToKeep = array("uName","uPass","uEmail","uDomain")
    strSessionsToDelete = ""
    for each objItem in Session.Contents
    OkayToDelete = True
    for each arrItem in arrSessionsToKeep
    if arrItem = objItem Then
    OkayToDelete = False
    exit for
    end if
    next
    if OkayToDelete then
    strSessionsToDelete = strSessionsToDelete & objItem & ","
    End If
    next
    arrSessionsToDelete = Split(strSessionsToDelete, ",")
    for each arrItem in arrSessionsToDelete
    Session.Contents.remove(CStr(arrItem))
    next
    ---------
    "Dan King" <> wrote in message
    news:...
    > At a summary page, I am trying to clean up Session.Contents so the user

    can
    > go back to the main page and not retain any unnecessary info.
    > I have entered this into my summary page, but it seems to only eliminate
    > every other or every third entry. If I refresh the page about 0 times
    > everything eventually clears out. Anyone know why it would do this?
    >
    > I don't want to use Session.Abandon because there are a few

    Session.Contents
    > I want to retain, like usernams and passwords.
    >
    > <%
    > ----snip----
    > For Each objItem in Session.Contents
    > Session.Contents.Remove objItem
    > Next
    > ----snip----
    > %>
    >
    > Session.Contents are being added like this:
    >
    > <%
    > ----snip----
    > Session("uName") = uName 'put info into a session variable
    > Session("uEmail") = uEmail 'put info into a session variable
    > Session("uPass") = uPass 'put info into a session variable
    > Session("uDomain") = uDomain 'put info into a session variable
    > ----snip----
    > %>
    >
    > Thanks
    >
    >
    > --
    > __o
    > _-\<,
    > (_)/(_)____
    >
    >
     
    Dan King, Oct 9, 2004
    #2
    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. Sky Sigal
    Replies:
    13
    Views:
    873
    Sky Sigal
    Aug 3, 2004
  2. Mantorok

    Cleaning up after sessions

    Mantorok, Sep 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    429
    Mantorok
    Sep 9, 2005
  3. Mantorok

    Cleaning up

    Mantorok, Sep 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    Chris Botha
    Sep 12, 2005
  4. Will Chamberlain

    Cleaning up Visual Studio's Directory Pollution

    Will Chamberlain, Oct 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    416
    Juan T. Llibre
    Oct 7, 2005
  5. Author #1
    Replies:
    3
    Views:
    800
    Author #1
    May 22, 2009
Loading...

Share This Page