Page 1 of 1

Problem with cookies

Posted: Sun Oct 28, 2007 6:17 pm
by blira
Hi all.

Here is my problem:

Page: login.php

Code: Select all

<head>
...
$cookie_data=$user."-".$pass."-".$role;
if(setcookie ("FLEISCHMANN_ADMIN",$cookie_data, $time+3600)==TRUE)
...
//Note $user, $pass, $role DO have data
</head>
Page: logged.php (once the login succeeds)

Code: Select all

<head>
...
$cook = explode("-", $_COOKIE['FLEISCHMANN_ADMIN']);	
$namecookie = $cook[0];
$passcookie = $cook[1];
$rolecookie = $cook[2];
...
</head>
$cook is empty and no cookie data is read... I've run out of ideas. Please help!

(note: when I open the cookie file, it DOES contain the data I'm trying to explode)

Thanks
Bernardo

Posted: Sun Oct 28, 2007 6:20 pm
by feyd
Cookies, like all other header interactions must be done before any output HTML or otherwise has been sent.

Posted: Sun Oct 28, 2007 6:33 pm
by blira
Yes, I understand that. I tried putting all the code before <HTML> and still nothing happens...

isset($_COOKIE['FLEISCHMANN_ADMIN']) is false (in the logged.php page).