Page 1 of 1

Getting data from cookie in PHP scripts

Posted: Sat Aug 24, 2002 4:11 am
by conthox
Hello

I have a loginscript that checks the username and password from a MySQL table, if you logged in correctly, a cookie will be set.

How do I get the information from the Cookie in a PHP-tag?

Something like this:

Code: Select all

<?php

if ($loggedin == 1) // check cookie info
&#123;
include "$username.php";
&#125; else &#123; 
header("Location: login.php");
&#125;
?>
Or something like that.

Thank you very much for helping me!

Posted: Sat Aug 24, 2002 4:38 am
by Takuma
PHP4.1+ -> You use $_COOKIE["username"]
PHP3 -> You use $HTTP_COOKIE_VARS["username"]

ok

Posted: Sat Aug 24, 2002 5:15 am
by conthox
Thanks, I'll try this.

I post a new reply if I can't get it to work.