Problem clearing session variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colinod
    Contributor
    • Nov 2007
    • 347

    Problem clearing session variable

    I have a session variable made up using the following code to keep a shopping basket type of arrangement

    Code:
    <%
    
    if InStr(session("recordsInCart"), ","&request.form("recordNum")) = 0 then 
       session("recordsInCart") = session("recordsInCart") + request.form("recordNum") &","
    else 
       'do nothing
    end if 
    %>
    I have a page that deletes a single item using the following

    Code:
    <% 
    If Not request.form("recordNum") ="" Then 
    CartItems = split(session("recordsInCart") ,",") 
    For Each Item in CartItems 
    If Not Item = request.form("recordNum") Then 
    If IsNumeric(Item) then newitems = newitems & Item & "," 
    End If 
    Next 
    session("recordsInCart") = left(newitems, len(newitems)) 'remove trailing comma from each loop iteration 
    End If   
    %>
    I am now tring to make a page that empties all the contents of the session variable in one click, i have tried the following
    Code:
    Session("recordsInCart") = ""
    Session.Abandon
    Session.Contents.RemoveAll()
    None of these work and do not empty my variable

    can anyone advise where i am going wrong??

    Thanks
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello colinod,

    Are you still having trouble with this?

    CroCrew~

    Comment

    • colinod
      Contributor
      • Nov 2007
      • 347

      #3
      No I managed to figure it out was trying to set cart to empty when I Shoul have been setting it to 0, strange but that's the way the code seemed to work

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        Cool,

        Happy programming...

        CroCrew~

        Comment

        Working...