kelleydl Posted August 25, 2009 Share Posted August 25, 2009 i am using a form with a name and state(location) and comment which when submit is clicked it takes me to post.php. post.php is where i set my cookie and it does its code, and then sends back to index.php. now i want name and location to be filled according to the cookie. post.php heading looks like this:<?php setcookie("lmylifemoments[two]", $_POST["uName"], "/"); setcookie("lmylifemoments[one]", $_POST["uLocation"], "/");?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>and then in index.php:<?php if(isset($_COOKIE['lmylifemoments'])) { $CNAME=$_COOKIE['lmylifemoments[two]']; $CLOC =$_COOKIE['lmylifemoments[one]']; } else { $CNAME = ""; $CLOC = ""; }?>i have that and in my form set values for name and location to $CNAME and $CLOC . when i test it nothing is being added to the fields and i dont know how else to debug for this.. maybe i am going about this the wrong way. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2009 Share Posted August 26, 2009 First, just print out the cookie array:print_r($_COOKIE);that will at least let you see all the cookies. You may want to remove the brackets from the cookie names, I'm not sure if that's going to be a problem. Also, if you're setting a cookie and then sending a location header, the cookie might not set. In that case it's better to use a meta refresh to redirect instead of a location header. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.