Forum Moderators: coopster
?php
//A PHP script that can set a Cookie read the Cookie and send the information to A script
class User
{
var $user="abe"; //Store's user's name
var $userName;
var $set;
function User($inName,$useName)
{
$this->userName=$inName;
$this->set=$useName;
}
function setFile() //Take's in a string and sets a cookie
{
$path="/php/"; //Sets the path the cookie can be read from (not used yet)
$time=time() + 400000000000000; //Sets the time when the Cookie will die at (not used yet)
$site="somesite.com"; //Sets the site name that set the Cookie (not used yet)
setcookie('name',$this->userName); //Sets the Cookie
}
function getUser()//sends back $user
{
return $this->user;
}
function setUser() //Sets value to $user
{
if($HTTP_COOKIE_VARS['name'])
{
$name=$HTTP_COOKIE_VARS['name'];
echo"$name";
}
else
{
echo"no";
}
}
}
?>
If i put
if($HTTP_COOKIE_VARS['name'])
{
$name=$HTTP_COOKIE_VARS['name'];
echo"$name";
}
else
{
echo"no";
}
in its own file it works fine.
Any one have any ideas?
[edited by: jatar_k at 7:27 pm (utc) on Jan. 6, 2003]
[edit reason] removed specifics [/edit]
You need to define $HTTP_COOKIE_VARS as global.
[php.net...]
Or better yet use the $_COOKIE [php.net] super global array.
Andreas