mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 13:44:58 +08:00
Clean up and document code
This commit is contained in:
parent
974f45e4e8
commit
8540932638
|
@ -30,7 +30,10 @@ class CookieFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* make a new cookie instance.
|
||||
* Make a new cookie instance.
|
||||
*
|
||||
* This method returns a cookie instance for use with the Set-Cookie HTTP header.
|
||||
* It will be pre-configured according to Flarum's base URL and protocol.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
|
@ -39,16 +42,13 @@ class CookieFactory
|
|||
*/
|
||||
public function make($name, $value = null, $maxAge = null)
|
||||
{
|
||||
// Parse the forum's base URL so that we can determine the optimal cookie settings
|
||||
$url = parse_url(rtrim($this->app->url(), '/'));
|
||||
|
||||
$path = array_get($url, 'path') ?: '/';
|
||||
|
||||
$secure = array_get($url, 'scheme') === 'https';
|
||||
|
||||
return SetCookie::create($name, $value)
|
||||
->withMaxAge($maxAge)
|
||||
->withPath($path)
|
||||
->withSecure($secure)
|
||||
->withPath(array_get($url, 'path') ?: '/')
|
||||
->withSecure(array_get($url, 'scheme') === 'https')
|
||||
->withHttpOnly(true)
|
||||
->withDomain(null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user