Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

erase a cookie NOW!!! 1

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
I am working on a website for a client, and am forced to use javascript to write the shopping cart. I have never done this before, but it is coming along well. here is my heres how it works:<br><br>when a page with items to buy on it loads, the cookie is read, and all items prevously in the cart are stored into an array.<br><br>If/when the user adds an item to the cart, it is just added to the array.<br><br>and then when they leave the page (onunload) the cookie is set, with all the old items, and all of the new ones.<br><br>my problem is when the page writes the cookie, instead of writing over the cookie, it just adds to it.<br><br><br>I tried putting a document.cookie='' in after the read function, I also tried putting a <br>document.cookie+='expires=Fri, 13-Apr-1970 00:00:00 GMT', both with no avail<br><br>thanks<br> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Dear Eclipse,<br><br>&gt; I tried putting a document.cookie='' in after the read function<br><br>I'm not sure I understand what 'after the read function' means but to delete your cookie try doing this:<br><br>document.cookie = mycookiename + &quot;=&quot; + escape('');<br><br>where &lt;mycookiename&gt; is the name of the cookie you want to delete.<br><br>Hope this helps<br>-pete<br>
 
thanks, I'll try that.<br><br>in the mean time,<br><br>&gt;after the read function<br><br>I have a function that reads the cookie into the array (the &quot;read function&quot;)<br><br>after the read function would then be the command after the calling statement.<br><br>ex:<br><br>readCookie();<br>document.cookie='';// the command &quot;after the read function&quot; <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
1) I hate cookies...<br>2) I hate cookies...<br>3) I hate cookies!<br><br>How many Items are available for purchase. Have you considered placing the info in the querystring of the url...<br><br>darg.htm<font color=red>?sneakers=3&toilets=2</font><br><br>I have a script that will extract these values and place them into an associative array for you...<br><br>I know I didn't answer your question, but heres the alternative...<br><br><A HREF="mailto:jared@aauser.com">jared@aauser.com</A>
 
I have thought about that as an alternative, and with each passing moment, the search string becomes more and more a better option.<br><br>The reason that I don't just use it is I would have to re-write the whole thing. oh well.<br><br>I would not need to use your script, as I have written one myself, thanks anyway.<br><br>I also am starting to hate cookies. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
In trying to implement the querystring shopping cart, I realized that one major flaw is present in that.<br><br>If the user presses the back button on their browser, then their shopping cart would be erased (aaaaaaaaaaahhhhhhh)<br><br>oh well, maybee I can convince him to pay for a host that supports a cgi-bin. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
I don't know much about JavaScript, but in ASP, ALL of the books I read said if you can get away from using cookies then do not use them.<br>Many users are under the impression you can get a virus or give away personal information when you allow cookies to 'live' on your machine.&nbsp;&nbsp;We all know this is bunk!&nbsp;&nbsp;But many people I know STILL turn off cookies for that reason; then your site will not work properly.<br>Try using a database or var's or somthing else instead of cookies.<br><br>I hope this saves you more time then it took me to rewrite my web.
 
Eclipse,<br><br>&gt; oh well, maybee I can convince him to pay for a host that supports a cgi-bin. <br><br>I'm sorry but that is just a big fat DUH! Trying to use state in client side only script is NOT an option for production applications.<br><br>&quot;But, that's just my opinion... I could be wrong&quot;.<br>-pete
 
palbano-<br>what is <br>&gt; trying to use state in client side only script ..<br><br>and its not my fault that he dosn't want to pay a 9.99 monthly fee for a server. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top