Date:  04/16/2006 07:22:12 PM Msg ID:  002927
From:  FoxWeb Support Thread:  002918
Subject:  Re: Remove QueryString
Are you trying to prevent an item from being added twice to the shopping cart in cases where the user pushes the refresh button after adding it once, or where the user clicks the "Add to cart" button and then clicks it again before the shopping cart page appears?  If this is the case, I have a better solution:
 
Whenever you return an "Add to cart" button to the browser, always include an instance ID query string variable.  In the following example this instance id is generated with the SYS(3) function.  The current channel is added to the string, because it's possible for two channels to generate the same instance id if they run at the exact same moment:
 

<a href="securecart.fwx?itemiID=<%=IID%>&page=tocart.fwx&instid=<%=SYS(3) + Server.CurChan%>">

 
You will need to modify securecart.fwx, so that it appends the current Instance ID to a InstIDList session variable, whenever it adds a new item to the cart.  Before doing so, it should verify that this instance ID has not already been sent in a previous request:
 

lcitemID=ALLTRIM(Request.QueryString("itemID"))
lcpage=ALLTRIM(Request.QueryString("page"))
lcInstID=Request.QueryString("InstID")
lcInstIDList = Session.GetVar('InstIDList')
If Not ',' + lcInstID + ',' $ InstIDList
   * Add this InstID to the list
   Session.SetVar('InstIDList', lcInstIDList + ',' + lcInstID + ',')
   * Code that adds the ItemID to a session variable
   .
   .
   .

End if

* Code that displays the contents shopping cart
.

.

.

 

FoxWeb Support Team
support@foxweb.com email

Sent by Joe Goldsmith on 04/16/2006 06:52:40 PM:
Hmmm, you had some nice ideas. Your first thought to place the querystring variable in a session variable is interesting. However, in my case that may not work. IN a shopping cart configuration the incoming varialbe is an item ID and we would like for the visitor to leave that cart and pur more stuff. The session variable may negate further pruchases unless I can release the session variable upon leaving the cart page.
 
Your second thought to call the cart page again with a blank value may work. Once I do with the passed value what I need I can reload the page with a blank value. I'll give that a try.
 
Thanks
 
Joe
Sent by FoxWeb Support on 04/15/2006 04:35:29 PM:
First let me make sure that we are talking about the same thing:  I assume that the "?=" syntax refers to the Query String portion of the URL.  Also, I assume that by "reload the page" you are referring to the Web browser's Reload, or Refresh button (or the equivalent function called from the menu, or by pressing Ctrl-R).  If the above assumptions are incorrect, please clarify.
 
All modern browsers make the exact same request as before when you press the Refresh button.  This means that there's no way to "remove" a query string variable.  However, there's a work-around:
 
Whenever your called script receives a request with the query string variable in question, store the fact that this has occurred in a session variable.  On all subsequent requests, even if the same query string variable is included in the URL, you will be able to ignore it, because the session variable will indicate that you have already performed the associated function in a previous request.
 
Another possibility would be for your script to issue a Response.Redirect to itself, with the original query string, minus the variable you don't want to see again.

FoxWeb Support Team
support@foxweb.com email

Sent by Joe Goldsmith on 04/13/2006 09:15:07 PM:
I have one script that calls another script passing a parameter using the ?= syntax. Once the called script gets the parameter I want to remove the instance of that, and only that, QueryString parameter so that when I reload the page it no longer responds to the passed variable. Anyone have an ides how to do that please?
 
Joe