mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-22 16:56:50 +01:00
Add Cookie::remove()
This commit is contained in:
parent
01e1da4ae3
commit
f5d224c8ec
@ -32,6 +32,16 @@ class Cookie
|
||||
Header::send('Set-Cookie', Header::make($data), $replace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a cookie
|
||||
*
|
||||
* @param bool $replace Whether to replace existing Set-Cookie header
|
||||
*/
|
||||
public static function remove(string $name, array $options = [], bool $replace = false): void
|
||||
{
|
||||
static::send($name, '', ['expires' => time() - 3600] + $options, $replace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array containing the default cookie directives
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ class Session
|
||||
Cookie::send(self::SESSION_NAME, session_id(), $options, true);
|
||||
} elseif (HTTPRequest::cookies()->get(self::SESSION_NAME) !== session_id()) {
|
||||
// Remove cookie if session id is not valid
|
||||
Cookie::send(self::SESSION_NAME, '', ['expires' => time() - 3600] + $options, true);
|
||||
Cookie::remove(self::SESSION_NAME, $options, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user