Hello there,
I want to create a simple user Cookie which if a user enters a name in the form and submits it it will show the username he entered..
Else it will show “Welcome Guest”.
Here’s what I have.
The Form:
[code=php]echo “<form action=’php.php’ method=’post’>
<input type=’text’ name=’userlog’ />
<input type=’submit’ name=’login’ value=’Log in’ />
</form>”;
The Cookie:
[code=php]$expire = time()+60*60*24*30*365;
if (isset($_POST[‘login’])) {
$user = $_POST[‘userlog’];
setcookie (‘logged’, $user, $expire);
if (isset($_COOKIE[‘logged’])) {
echo “Welcome : ” . $_COOKIE[‘logged’] ;
}
}
else {
echo “Welcome : Guest” ;
}