View Single Post
  #1 (permalink)  
Old 05-17-04, 03:37 AM
robii1 robii1 is offline
New Member
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with PHP cookies

This is the first time I've tried to use PHP cookies so I'm stuck and don't have any idea what the problem is

I have tried to set a cookie on the following page: www.formymobile.co.uk/test2100fascias.shtml

The code looks like this:

<?php
setcookie("fasciaoffer", $name, time()+36000);
?>
<html>

I have checked & this does set a cookie on my pc

I then want to retrieve the cookie when my customer views their shopping basket and display a message

The code in my shopping basket is:

<?php
if (isset($_COOKIE["fasciaoffer"]))
echo "<b>Special offers available</b> - buy any 3 covers & get your 4th choice free! " . $_COOKIE["fasciaoffer"] . "!<br />";
else
echo "<b>Special offers available</b> - none available on current order<br />";
?>

The problem is as follows - even though I have the cookie on my pc, the message that comes up in my shopping basket is the one where the cookie has not be found

Anybody have any ideas about what the problem could be? Is my coding correct?

Also, I don't know if this makes any difference, but the file which the retrieve bit is in (the shopping basket) is not in the root folder

Thanks

Robert
Reply With Quote