I am training from the book, “MacroMedia DreamWeaver 8,
Training from the Source.” I am unable to get retrieve the cookies
set on my hard drive by the code I used in Chapter 4, Setting and
Retrieving Cookies. I have checked my code against the completed
code in the book and they appear to me to be identical. The cookies
are being transferred to my hard drive by by the variables set in
the code, but the code fails to retrieve the cookies from the hard
drive as expected on the linked page. Since I eventually want to
develop an interactive commerical web site, I need to solve this
problem now. Any help is certainly appreciated. Below, I am listing
the code that I am using for each of the three dynamic pages.

Test Form:

Information is entered on this form and passed to test form
processor (This works well.)

[

Code]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Transitional//EN” ”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”
http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=”Content-Type” content=”text/html;
charset=iso-8859-1″ />

<title>Untitled Document</title>

</head>

<body>

<form id=”frm_name” name=”frm_name” method=”get”
action=”test_form_processor.php”>

<label>First Name

<input name=”firstName” type=”text” id=”firstName” />

</label>

<p>

<label>Last Name

<input name=”lastName” type=”text” id=”lastName” />

</label>

</p>

<p>

<p>

<input type=”submit” name=”Submit” value=”Submit” />

</p>

</form>

</body>

</html>

[/Code]

Test Form Processor:

The first name and last name from page one transfer to the
variables on this page, no problem.

[Code]

<?php

setcookie(‘firstName’, $_Get['firstName'], time() +
(60*60*24));

setcookie(‘lastName’, $_Get['lastName'], time() +
(60*60*24));

?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Transitional//EN” ”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”
http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=”Content-Type” content=”text/html;
charset=iso-8859-1″ />

<title>Untitled Document</title>

</head>

<body>

<p>Thank you, <?php echo $_GET['firstName']; ?>
<?php echo $_GET['lastName']; ?> , for filling out my
form.</p>

<p>Check <a
href=”test_form_processor_cookies.php”>cookie</a>.
</p>

</body>

</html>

]/Code]

Test form processor cookies:

The cookies sre transferred to my hard drive, I checked by
looking in the browser cache. the problem is that the cookies are
not retrieved by this page. When I click on the link to this page,
“I get Hi, !.” Why won’t the code echo the variables that the
cookies are holding? The code is below.

[Code]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Transitional//EN” ”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”
http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=”Content-Type” content=”text/html;
charset=iso-8859-1″ />

<title>Untitled Document</title>

</head>

<body>

Hi, <?php echo $_COOKIE['firstName']; ?> <?php echo
$_COOKIE['lastName']; ?> !</body>

</html>

[/Code]

All the bindings are set, the cookies are placed on the hard
drive, but for some reason the link page does not retrieve the
cookies and print them to the screen as expected. I use Firefox and
IE7. I set both to accept totally cookies, still I cannot retrieve
the cookie set by this small application from my hard drive, when I
run the pages. Any help and are ideas are appreciatted.

|||
The problem is in the Set Cookie header on page two. It
should be $_GET and not $_get. Dreamweaver uses lower case with the
get method. The correct $_GET is displayed in blue letters in upper
case, instead of black letters and lower case. This is a very
subtle difference, as PHP uses the get method in lower case.

Related posts:

  1. Setting &amp; Retrieving Session Variables
  2. cfinput type=&quot;checkbox&quot; default value not posting
  3. &quot;#&quot; in form field?
  4. Setting a &quot;set home page&quot; and &quot;add to favorite&quot; link
  5. accordian panel &quot;flashes&quot;

Related posts brought to you by Yet Another Related Posts Plugin.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 free icons download Suffusion theme by Sayontan Sinha

Featuring Recent Posts WordPress Widget development by YD