title: Not able to set cookies from form with php
body: <p>I have checked the code many times, yet not able to find the error! the issetCookie returns false here.</p>
  
  <pre><code>&lt;html&gt;
   &lt;body&gt;
     &lt;?php if(!isset($_REQUEST['sub'])) { ?&gt;
     &lt;form name="f1" action="1.php" method="post"&gt;
       Name : &lt;input type="text" name="na"&gt;&lt;br&gt;
       Last Name : &lt;input type="text" name="lna"&gt;&lt;br&gt;
       Email Id : &lt;input type="text" name="eml"&gt;&lt;br&gt;
       Phone No : &lt;input type="text" name="phn"&gt;&lt;br&gt;
       City : &lt;input type="text" name="cty"&gt;&lt;br&gt;
       &lt;input type="Submit" name="sub" value="ok"&gt;&lt;input type="Reset" name="res" value="Clear"&gt;
    &lt;?php } else {
       $name=$_REQUEST['na'];
       $lname=$_REQUEST['lna'];
       $email=$_REQUEST['eml'];
       $phone=$_REQUEST['phn'];
       $city=$_REQUEST['cty'];
  
       setcookie("Name", $name, time()+3600, "/","", 0);
       setcookie("LName",$lname);
       setcookie("Email",$email);
       setcookie("Phone",$phone);
       setcookie("City",$city);
    } ?&gt;
    &lt;/form&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can someone help me to <strong>assign variables to cookie</strong>?
  If its the issue of else, please suggest alternate options of assigning cookie value using form data and retrieving on the next page defined in form action.</p>