Ok i'll try to make this as simple as possible.
Im making a login system, and for that im making a function wich makes it possible to stay logged.
So for this purpose i want to use cookies (first time im using them, silly i know)
bassicly the procedure takes place over 3 documents.
a start.php (wrapped around all pages and contains the html headers and so forth)
a login.php (the page with the login form)
and a cookin.php (tbe page wich sets the cookie)
ok so in login.php i start a session for the login containing the user id from the database.
after setting the session($_SESSION['theuser']) it jumps to cookin.php where it sets a variable before start.php called $storecookie = 1; then in the start.php (before <html>) i have an if command called
<?php if ($storecookie == 1) { setcookie("userlogincookie", $_SESSION['theuser'], time()+60*60*24*30); } ?>
and then later down on the start.php i have
if (isset($_COOKIE['userlogincookie'])) {
$theusersid = $_COOKIE['userlogincookie'];
}
and if the page gets feeded with a $theusersid it looks it up in the db and tells the page that that user is logged in.
I did it the same way before where login.php just jumped directly to the frontpage and it then checked for a $_SESSION in the start.php instead of a cookie, and that worked perfectly (besides it logged out everytime you closed the browser ofc.)
Anyways the problem is that everytime i go to another page or close the browser it logs out again. As if the cookie didnt get stored right.
I hope someone will be able to help me with this.