Jump to content
Larry Ullman's Book Forums

Recommended Posts

I'm having trouble getting my cookie values created in customize.php to modify the text in view_settings.php. When I view the stored cookies on my Mac 10.5.8 (Safari 5.0.6), they appear in the list of cookies. In fact, when I make different selections for font_size and font_color, they are reflected in the browser list of cookies as intended. The problem appears when the view_settings.php page is not affected by the change in values. I tried to print out the values of font_size and font_color after the setcookie commands on the customize.php page but receive no values for each.


setcookie('font_size', $_POST['font_size'], time()+1200);

setcookie('font_color', $_POST['font_color'], time()+1200);

print "<p> the font size is..." . $_COOKIE['font_size'] . "and the font color is..." . $_COOKIE['font_color'] . "</p>";


I get this result...


the font size is...and the font color is...

Your settings have been entered! Click here to see them in action.


The values for $_POST['font_size'] and $_POST['font_color'] are available and correct when I print them out.

I even tried to upload script_09_01.php and script_09_02.php directly to the web hosting server that I am using and those did not work either. Any ideas?

Link to comment
Share on other sites

It partially works for me. I selected font-size small and color blue and it printed "the font size is...land the font color is..." and when I click the link it appears small and blue. View source and font-size is set to small and color to #00f. If I select the Customize Your Settings link and select large and gray, it prints "the font size is...smalland the font color is...00f" and the text appears large and gray when I click the link. View source shows font-size: large; color: #999. Select Customize Your Settings again, and select medium and red and it says "the font size is...largeand the font color is...999" and the link displays medium text in red. View source shows font-size: medium, color: #c00.


It appears that the cookie is not displaying the updated values, but the value that was set previously. Also, you must select both the size and color. If you only select one, the cookie value for the omitted option is set to an empty string.


This is tested using Firefox 14.0.1 on Windows 7.

  • Upvote 1
Link to comment
Share on other sites


  • Create New...