Page 1 of 1
I wanna cookie, please.
Posted: Thu Aug 08, 2002 11:03 pm
by lexx
Hehe I know that there are whole bunch of tutorials on cookies on stuff but I dont get them. So can someone write me a code for cookie that stores $user and $password and expires in 1 hour and code that gets $user and $password from that cookie. comments in the code are very welcomed.
Thanks for any help.
Posted: Fri Aug 09, 2002 2:26 am
by twigletmac
This is not a script-writing service, if you are looking for pre-made scripts go to
http://www.hotscripts.com, if you want to pay someone to write your scripts for you go to the
Jobs Forum.
Mac
Posted: Fri Aug 09, 2002 12:53 pm
by lexx
But I wanna cookie

Ok thanks
Posted: Fri Aug 09, 2002 1:38 pm
by lexx
At least help me understand it...
<?
//Write a cookie.php
$user_name="me";
$user_password="knocking";
$user_input="$user_name,$user_password";
setcookie("login",$user_input,time()+600);
// Cookie name "login" is dded to users computer containing "$user_input
// right?
?>
How do you get "$user_input" from that cookie?
Posted: Fri Aug 09, 2002 2:30 pm
by RandomEngy
Code: Select all
$cookie_array = array(
"user" => $username,
"pass" => $password );
set_cookie("login",serialize($cookie_array),time()+600);
Would create a 10 minute cookie. To get the values out,
Code: Select all
$cookie_output_array = unserialize($_COOKIEї'login']);
$username = $cookie_output_arrayї'user'];
$password = $cookie_output_arrayї'pass'];
You could also use explode() and implode() if you don't need to use an associative array.
Posted: Fri Aug 09, 2002 3:32 pm
by lexx
the set cookie works but the other thing doesnt...?
Hey
Posted: Fri Aug 09, 2002 3:46 pm
by Takuma
Which script wasn't working?
P.S. If you want a cookie go and buy it

Posted: Fri Aug 09, 2002 5:48 pm
by lexx
Code: Select all
їquote]$cookie_output_array = unserialize($_COOKIEї'login']);
$username = $cookie_output_arrayї'user'];
$password = $cookie_output_arrayї'pass'];ї/quote]
echo $username;
echo $password;
Nothing happends
Posted: Sun Aug 11, 2002 3:40 am
by Takuma
lexx wrote:Code: Select all
cookie_output_array = unserialize($_COOKIEї'login']);
$username = $cookie_output_arrayї'user'];
$password = $cookie_output_arrayї'pass']
echo $username;
echo $password;
Nothing happends
Have you set the cookie, "login"? And also what does $_COOKIE["login"] return?