forms - PHP Cookie Issue -


this question has answer here:

i trying create html form username, name, , email address , php store username cookie. then, store username, name, , email address.

then, when log go form again, form greet user cookie information. unsure how proceed, if can give me suggestions. thanks!

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <title></title>      <form action = "userinfo.php" method = "post">          username:<br>         <input type="text" name="username">         <br>          fullname:<br>         <input type="text" name="fullname">          <br> email:<br>         <input type="text" name="email">         <br>         <input type="submit" value="submit">      </form>  </head> <body>  </body> </html>    <?php  session_start();  $cookie_name = "user"; $cookie_value = "username"; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day   if (!isset($_cookie[$cookie_name])) {     echo "cookie named '" . $cookie_name . "' not set!"; } else {     echo "cookie '" . $cookie_name . "' set!<br>";     echo "value is: " . $_cookie[$cookie_name]; }  ?> 

php superglobal ($_get, $_post, $_server, $_cookie, etc...) set once when script first starts up, , never changed again php.

whatever cookies create setcookie() appear in $_cookie on next script execution.

the sole exception $_session, gets populated after session_start() called.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -