common\Cookie::delete PHP Method

delete() public static method

This overwrites the spoon cookie method and adds the same functionality as in the set method to automatically set the domain.
public static delete ( )
    public static function delete()
    {
        $domain = null;
        if (FrontendModel::getContainer()->has('request')) {
            $domain = '.' . FrontendModel::getContainer()->get('request')->getHost();
        }
        foreach (func_get_args() as $argument) {
            // multiple arguments are given
            if (is_array($argument)) {
                foreach ($argument as $key) {
                    self::delete($key);
                }
            } else {
                // delete the given cookie
                unset($_COOKIE[(string) $argument]);
                setcookie((string) $argument, null, 1, '/', $domain);
            }
        }
    }

Usage Example

Example #1
0
 /**
  * Logout a profile.
  */
 public static function logout()
 {
     // delete session records
     FrontendModel::getContainer()->get('database')->delete('profiles_sessions', 'session_id = ?', array(\SpoonSession::getSessionId()));
     // set is_logged_in to false
     \SpoonSession::set('frontend_profile_logged_in', false);
     // delete cookie
     CommonCookie::delete('frontend_profile_secret_key');
 }