PDA

Click to See Complete Forum and Search --> : [RESOLVED] Setting Cookie


dclamp
Jul 1st, 2007, 01:51 PM
I have the following code located at the top of my page:


//Checks if the forum was submited...
if ($_POST['email'] == "" && $_POST['password'] =="") {
//if it was not, check to see if cookies exist...
if (isset($_COOKIE['email']) && isset($_COOKIE['password'])) {
//if so, set in a var and put in a textbox
$mememail = $_COOKIE['email'];
$mempassword = $_COOKIE['password'];
} else {
if their not set, make vars = to nothing
$mememail = "";
$mempassword = "";
}
} else {
//form was submited, set cookies if checked
if ($_POST['remeber']=="checked") {
setcookie("email", $_POST['email']);
setcookie("password", $_POST['password']);
}
}


and it doesnt work. :(. There are no error, it just doesnt call the cookie. I dont think it is set right.

visualAd
Jul 1st, 2007, 04:13 PM
If you set error_reporting(E_ALL) then you will find out why your code doesn't work ;).

dclamp
Jul 1st, 2007, 11:11 PM
i dont have access to my php.ini file though.

penagate
Jul 2nd, 2007, 03:30 AM
error_reporting is a function. Call it at the top of your script:

<?php
error_reporting(E_ALL ^ E_STRICT);

// rest of code
?>


And then fix any notices/warnings/errors that are produced. You should do this for all scripts.

lintz
Jul 2nd, 2007, 04:09 AM
Do the cookies (munch, munch, yum, yum :bigyello: ) actually exist?

If you're using IE7 (or plugin for IE6) or FF you can view all the current cookies saved which is a good way to check :thumb:

dclamp
Jul 12th, 2007, 12:12 AM
i think i figured it out. Thanks guys :)

I_Love_My_Vans
Jul 15th, 2007, 07:02 AM
DClamp can you tell us what went wrong?

Would be useful to know for future searches :D


ILMV

dclamp
Jul 15th, 2007, 02:23 PM
quite frankly, i have no idea. I would love to tell you but i dont know :(