[plug] Cookie problems ..

Mark J Gaynor mark at scouts.org.au
Tue Feb 18 14:59:36 WST 2003


Hi all,

I have an application using cookies and is failing with the following error.

-------------
Warning: setcookie() expects parameter 3 to be long, string given in 
/var/www/ad/ad/admin.php on line 144

Warning: setcookie() expects parameter 3 to be long, string given in 
/var/www/ad/ad/admin.php on line 146

Warning: Cannot add header information - headers already sent by (output 
started at /var/www/ad/ad/admin.php:144) in /var/www/ad/ad/admin.php on 
line 147
-------------

Doing a search on the error on the net only gave more instances of the same 
error and no solution.

Can anyone throw any light on the subject for me please. (I have not dealt 
with cookies before)

This is the function in question.
// ------------------------------
function check_login () {
         GLOBAL $my_user, $my_pass, $PHP_SELF;

         $my_user = eregi_replace('[^a-z0-9_-]','',$my_user);
         $my_pass = eregi_replace('[^a-z0-9_-]','',$my_pass);
         $my_user = strtolower("$my_user");

         if ($my_user == "" || $my_pass == "") {
                 header1();
                 error_ad("both fields are required");
         }
         include("config.php");
         if ($my_user != $username) {
                 $error = 1;
         }
         if ($my_pass != $password) {
                 $error = 1;
         }
         if ($error) {
                 header1();
                 error_ad("you did not enter in the correct 
username/password comination");
         }

         $password = crypt("$my_pass","salt123");
         SetCookie("ad_name",$my_user,"", "/");
         $password = eregi_replace('[^a-z0-9_-]','',$password);
         SetCookie("ad_pass",$password,"", "/");
         header("Location: $PHP_SELF?cookies=turned_off");
         exit;

}
// ------------------------------


Mark
--



More information about the plug mailing list