468,540 Members | 2,118 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,540 developers. It's quick & easy.

Problem clearing session variable

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

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. if InStr(session("recordsInCart"), ","&request.form("recordNum")) = 0 then 
  4.    session("recordsInCart") = session("recordsInCart") + request.form("recordNum") &","
  5. else 
  6.    'do nothing
  7. end if 
  8. %>
I have a page that deletes a single item using the following

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. If Not request.form("recordNum") ="" Then 
  3. CartItems = split(session("recordsInCart") ,",") 
  4. For Each Item in CartItems 
  5. If Not Item = request.form("recordNum") Then 
  6. If IsNumeric(Item) then newitems = newitems & Item & "," 
  7. End If 
  8. Next 
  9. session("recordsInCart") = left(newitems, len(newitems)) 'remove trailing comma from each loop iteration 
  10. End If   
  11. %> 
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
Expand|Select|Wrap|Line Numbers
  1. Session("recordsInCart") = ""
  2. Session.Abandon
  3. Session.Contents.RemoveAll()
None of these work and do not empty my variable

can anyone advise where i am going wrong??

Thanks
Nov 14 '11 #1
3 1555
CroCrew
564 Expert 512MB
Hello colinod,

Are you still having trouble with this?

CroCrew~
Nov 17 '11 #2
colinod
347 100+
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
Nov 17 '11 #3
CroCrew
564 Expert 512MB
Cool,

Happy programming...

CroCrew~
Nov 18 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Anthony | last post: by
3 posts views Thread by vvenk | last post: by
4 posts views Thread by Amy | last post: by
1 post views Thread by stathisgotsis | last post: by
reply views Thread by Pankaj | last post: by
9 posts views Thread by arial | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.