473,378 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1731
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

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

Similar topics

1
by: Anthony | last post by:
I have a php app that is in the final stages of testing and has been tested by over 30 separate users. One of the testers is having an intermittent problem which seems to be caused by a session...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
3
by: vvenk | last post by:
Hello: This was posted in a wrong forum; that's why I am posting here again. Sorry. I just wrote my first ASP.Net application, tested it on my development environment and deployed it on a...
4
by: Amy | last post by:
I'm having a problem with clearing my session variables. I'm using session variables to pass data from a web form to a pdf generator. The problem comes in when a user goes back to the original...
1
by: stathisgotsis | last post by:
I am building a site and i want to password protect some pages. In order to do this i use this variable: $_SESSION and i set it to true when a user has logged in. So in one file when a user has...
0
by: Pankaj | last post by:
Hi, I am facing a problem in accessing ASP.NET pages. I developed a application in ASP.NET 2003 that when calls open a sign- in page by verifying userid in oracle database and open a main...
6
by: Ken Varn | last post by:
When I am running my ASP.NET 2.0 application using VS.NET 2005 ASP.NET Development Server, the session state seems to be getting lost at various times without warning. I am not sure why this is...
1
by: sbettadpur | last post by:
hi everybody, l have one doubt, please clarify that if anybody knows. Can i able to take database connection across the page through session variable, without initializing connection on every...
12
by: arial | last post by:
Hi all, I really need some help. I have a asp.net web project using c#. I have put one of my datafield in session in one webform and I am calling that same datafield of the session to another...
9
by: arial | last post by:
Hi all, I have problem with session variable on .net web form. I am saving ID in session to pull up the other .net web form it works fine with my development environment but as soon as I put...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.