Getting data from cookie in PHP scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

Getting data from cookie in PHP scripts

Post 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!
Last edited by conthox on Sat Aug 24, 2002 5:13 am, edited 1 time in total.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

PHP4.1+ -> You use $_COOKIE["username"]
PHP3 -> You use $HTTP_COOKIE_VARS["username"]
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

ok

Post by conthox »

Thanks, I'll try this.

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