[PHP] Cool Cookie Login/Logout/Control Panel
Just was messing arround.
And got this.
Example: http://elitetactics.sytes.net/login.php
Login.php
PHP Code:
<form action='cp.php?' name='login' action='get'>
User <input type='text' name='user'><br>
Pass <input type='password' name='pass'><br>
Email <input type='text' name='mail'><br>
<input type='submit' value='Login'>
</form>
Cp.php
PHP Code:
<?php
$user2=$_GET['user'];
$pass2=$_GET['pass'];
$email=$_GET['mail'];
setcookie("user", $user2, time()+3600);
setcookie("pass", $pass2, time()+3600);
setcookie("mail", $email, time()+3600);
?>
<html>
<body>
<?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome Guest!<br />";
?>
<?php
if (isset($_COOKIE["pass"]))
echo "Your Password is " . $_COOKIE["pass"] . "!<br />";
else
echo "No Password<br />";
?>
<?php
if (isset($_COOKIE["mail"]))
echo "Your Email is " . $_COOKIE["mail"] . "!<br />";
else
echo "No Email<br />";
?>
<br><b><a href=logout.php>Logout</a>
<br><b><a href=login.php>Sing In</a></b>
<br>Refresh For your information to appear.
</body>
</html>
logout.php
PHP Code:
<?php
setcookie("user", $user, time()-3600);
?>
<?php
setcookie("pass", $pass2, time()-3600);
?>
<?php
setcookie("mail", $email, time()-3600);
?>
You are loggout out.<br><b>
<a href=login.php>Sign in</a><br>
<a href=cp.php>Control Panel</a>
Kinda Cool...No need to change anything in the files.
Start at login.php
Re: [PHP] Cool Cookie Login/Logout/Control Panel
This is truly dreadful code.
How about you actually learn php before you go around teaching people about it.
Re: [PHP] Cool Cookie Login/Logout/Control Panel
Quote:
Originally Posted by
Pieman
This is truly dreadful code.
How about you actually learn php before you go around teaching people about it.
you know,,
I can't agree more with you ,, :P
Re: [PHP] Cool Cookie Login/Logout/Control Panel
lmfao.. That's a piece of shat
Re: [PHP] Cool Cookie Login/Logout/Control Panel
and just because I want, I'm gonna edit this and make it abit better :P
PHP Code:
<?php
$do = (isset($_GET['do']) ? $_GET['do'] : "0");
if($do == '0') {
echo '
<form action='?do=1' name='login' method='post' enctype='multipart/form-data'>
User <input type='text' name='user'><br>
Pass <input type='password' name='pass'><br>
Email <input type='text' name='mail'><br>
<input type='submit' value='Login'>
</form>
';
} elseif($do == '1') {
$username = 'AngryCat';
$password = md5('mysecretpassword');
$user2 = $_GET['user'];
$pass2 = md5($_GET['pass']);
$email = $_GET['mail'];
if($user2 != $username) {
echo 'Wrong Username';
exit();
}
if($pass2 != $password) {
echo 'Wrong Password';
exit();
}
setcookie("user", $user2, time()+3600);
setcookie("pass", $pass2, time()+3600);
setcookie("mail", $email, time()+3600);
echo '<html>';
echo '<body>';
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome Guest!<br />";
if (isset($_COOKIE["mail"]))
echo "Your Email is " . $_COOKIE["mail"] . "!<br />";
else
echo "No Email<br />";
echo '
<br><b><a href="?do=2">Logout</a>
<br><b><a href="?">Sing In</a></b>
<br>Refresh For your information to appear.
</body>
</html>
';
} elseif($do == '2') {
<?php
setcookie("user", $user, time()-3600);
setcookie("pass", $pass2, time()-3600);
setcookie("mail", $email, time()-3600);
echo '
You are now logged out out.<br><b>
<a href="?">Sign in</a><br>
';
}
PS: might not work, did this in 2 min :P
And Daevius, if this isn't allowed, I'm sorry, I just had to :P
Re: [PHP] Cool Cookie Login/Logout/Control Panel
Quote:
Originally Posted by
AngryCat
And Daevius, if this isn't allowed, I'm sorry, I just had to :P
^^, you're perfectly safe.
I would, however, add AStyle indention, but thats just preference ;)
Re: [PHP] Cool Cookie Login/Logout/Control Panel
Cookies are useless.. Using a get method on a login makes users feel insecure when they see their password sitting up in the address bar.. Any spyware on the user's computer will get them hacked.. That's why cookies are overrated.. Use a session, and use post method...
Also, Something similar to mcrypt_encrypt($password,password) isn't that hard of a line to write.
My syntax isn't really right, but here:
http://www.php.net/manual/en/functio...pt-encrypt.php
Re: [PHP] Cool Cookie Login/Logout/Control Panel
Im using sessions aswell - alot safer
Re: [PHP] Cool Cookie Login/Logout/Control Panel
Quote:
Originally Posted by
s-p-n
Cookies are useless.. Using a get method on a login makes users feel insecure when they see their password sitting up in the address bar.. Any spyware on the user's computer will get them hacked.. That's why cookies are overrated.. Use a session, and use post method...
Also, Something similar to mcrypt_encrypt($password,password) isn't that hard of a line to write.
My syntax isn't really right, but here:
http://www.php.net/manual/en/functio...pt-encrypt.php
I don't entirely agree with you, cookies can be safe but most people have no clue how to do this and just store plain passwords in cookies. Also, most people don't have a clue of when to use cookies. Cookies should only be used when things should be stored client side over a prolonged period of time.
I myself only use cookies for the "Remember me" option on my blog.