note 28468 added to function.setcookie

From: Date: Tue, 14 Jan 2003 10:58:11 +0000
Subject: note 28468 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-42113@lists.php.net to get a copy of this message
I'm creating an e-commerce website, and I just need clarification as to whether a MySQL query is considered as "browser output". I ask because I have the following code, but the cookie isn't being set: if (mysql_num_rows(mysql_query("select * from $cart->user_table where username=\"$username\" and userpass=\"$userpass\"", $cart->dblink)) != 1) { $errormsg = "Invalid username or password. Please try again."; } else { setcookie("jackloren_user", "$username:$userpass", time() + 2592000); // expires in 30 days } The cookie is able to be set before the query, but not after. Is a MySQL query considered as that dreaded browser output that messes up cookie creation? And if so, why? And finally, has anyone found a way around this problem without hindering the functionality of the script? Thanks. Dogga -- http://www.php.net/manual/en/function.setcookie.php http://master.php.net/manage/user-notes.php?action=edit+28468 http://master.php.net/manage/user-notes.php?action=delete+28468 http://master.php.net/manage/user-notes.php?action=reject+28468

« previous php.notes (#42113) next »