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

Problem clearing session variable

100+
P: 347
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
Share this Question
Share on Google+
3 Replies


CroCrew
Expert 100+
P: 563
Hello colinod,

Are you still having trouble with this?

CroCrew~
Nov 17 '11 #2

100+
P: 347
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
Expert 100+
P: 563
Cool,

Happy programming...

CroCrew~
Nov 18 '11 #4

Post your reply

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