Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Perl (http://www.programmingforums.org/forum21.html)
-   -   Removing Cookies (http://www.programmingforums.org/showthread.php?t=1456)

eggsy Dec 7th, 2004 2:41 PM

Hi all much help needed??

I have had to develop a site in Perl that acts as a very basic e-commerce system whihc tracks items ordered in Cookies.

Code for adding cookies is shown below:

$cookie_value = $query->cookie('cycle');
#cookie value is called 'cycle'

$cycle_to_add = $query->param('cycleid');

if ($cookie_value)
{

$cookie_value = $cookie_value . ',';

}


$cookie_value = $cookie_value . $cycle_to_add;


$cookie_to_set = $query->cookie (-name => 'cycle',

-value => $cookie_value,

-expires=> '',

-path=> '/');

print $query->header(-cookie => $cookie_to_set);[/b]

What I am also looking to do is make it so that people can remove items from their shopping basket?
and having real problems in how to go about this.

Code for area of the shopping basket is shown below:

$sql = qq{SELECT name FROM stock WHERE item_id = ?};



$sth = $dbh -> prepare($sql);



@cycle_list = split /,/, $cookie_value;

print "<FORM METHOD=post ACTION=\"redirect.pl\">\n\n";
print "<CENTER><FONT FACE = \"arial, helvetica, sans\"><TABLE COLS=3>";


foreach $cycleid (@cycle_list)
{



$sth -> execute($cycleid);



($name) = $sth->fetchrow_array;



print "<TR><TD>$name</TD><TD></TD><TD><A HREF=remProduct.pl?id=$cycleid>REMOVE</A></TD></TR>\n";

}

print "</TABLE>\n";[/b]

So it will pass the Cycle ID to the remProduct Perl file I just dont know where to go from there?

If anyone can help would be really useful thanks all for reading, any more info needed please let me know??

mackenga May 2nd, 2005 12:48 PM

Can't really make out your code very well because of the invasion of smilies; maybe I'd get a better look at it if you wrapped it up in code tags.

It may not be necessary, though, if this answer is good enough. If I get the gist and you're just wondering how to clear a cookie using CGI.pm, I'm pretty sure it's the same as setting one, but you set its value to undef.

Like I say, I'm pretty sure this will work. Alternatively, how about setting it, but setting its expiry time to now?


All times are GMT -5. The time now is 3:24 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC