/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* These are our valid username and passwords */ $user = 'jonny4'; $pass = 'delafoo'; if (($_POST['username'] == $user) && ($_POST['password'] == $pass)) { /* Set cookie to last 1 year */ } else { /* Cookie expires when browser closes */ } } else { echo 'Username/Password Invalid'; } } else { echo 'You must supply a username and password.'; } ?> <?php /* These are our valid username and passwords */ $user = 'jonny4'; $pass = 'delafoo'; } else { echo 'Welcome back ' . $_COOKIE['username']; } } else { } ?>
URL: http://www.phpnerds.com/article/using-cookies-in-php/2
Comments
