
 Darren Conyard - 2013-01-09 14:09:44 - 
In reply to message 2 from Archzilon Eshun-DaviesHi Arch,
I think I need to explain myself better here too. This is one is a little trickier but hopefully it makes sense. So in this class theres two files cCookies.php and example.php. This is the code from example.php:
<?php 
ini_set("display_errors", 1);
require_once("cCookies.php"); 
$cookie = new cCookies; 
$cookie->set('name', 'value'); // this cookie would disappear 
// after you close the brwoser session
$cookie_name = $cookie->get('name'); 
if ($cookie_name != null) 
echo $cookie_name; 
else 
echo "Cookie not found :( you make cookie monster sad."; 
$cookie->destroy('name'); 
unset($cookie); 
?>
The text printed on screen is:
Cookie not found :( you make cookie monster sad.
So I thought I would try and solve the problem by first of all seeing where the problem lies. Within cCookies.php I have added the following lines of code:
public static function set( $name, $value, $expire=0, $path='/', $domain='localhost', $secure=0, $httponly=0 )
{	
echo "setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly )";
$ret = setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly );
if( $ret ) {
	return true;
	} else {
	return false;
    }
}
When running this code I can see that the cookie is being set correctly, from the text printed:
setcookie( name, value, 0, /, localhost, 0, 0 )Cookie not found :( you make cookie monster sad.setcookie( name, , 530492400, /, localhost, 0, 0 )
So I do not think the problem is with the set function. So now I want to test the get function and I do so with the following code:
public static function get( $name ) {
    echo $name;
    if(isset($_COOKIE[$name])) {
        echo "richtig";
    } else {
        echo "falsch";
    }
return( (isset($_COOKIE[$name])) ? $_COOKIE[$name] : null );
}
This code then prints the following text:
namefalschCookie not found :( you make cookie monster sad.
So from what I can tell the cookie $name is not set properly but I do not know why :(
Hopefully this helps.
Best Regards
Darren Conyard