<?php

require_once("tokenstrategy.php");

class CookieStrategy extends TokenStrategy
{
    /**
     * the name for the cookie
     */
    const COOKIENAME = "token";

    public function getAuthToken()
    {
        return $_COOKIE[self::COOKIENAME];
    }

    public function setNextAuthToken($token)
    {
        $expiry = Configuration::getInstance()->getConfig("cookie_expiry_time");
        if ($expiry == null)
        {
            throw new Exception("no cookie expiry time found in config file", E_NO_EXPIRY_TIME);
        }
        setcookie(
                  self::COOKIENAME,
                  $token,
                  time() + (int)$expiry
                 );
    }

    public function removeAuthToken()
    {
        setcookie (self::COOKIENAME, "", time() - 3600);
    }

}

<?php

require_once("tokenstrategy.php");

class CookieStrategy extends TokenStrategy
{
    /**
     * the name for the cookie
     */
    const COOKIENAME = "token";

    public function getAuthToken()
    {
        return $_COOKIE[self::COOKIENAME];
    }

    public function setNextAuthToken($token)
    {
        $expiry = Configuration::getInstance()->getConfig("cookie_expiry_time");
        if ($expiry == null)
        {
            throw new Exception("no cookie expiry time found in config file", E_NO_EXPIRY_TIME);
        }
        setcookie(
                  self::COOKIENAME,
                  $token,
                  time() + (int)$expiry,
                  $_SERVER['SCRIPT_NAME']
                 );
    }

    public function removeAuthToken()
    {
        setcookie (self::COOKIENAME, "", time() - 3600);
    }

}

Set the cookie path properly.
Set the cookie path properly.

This is needed so that the cookies are valid for
(only) us, and so that they're easier to track.
