mirror of
https://github.com/flarum/core.git
synced 2025-10-14 16:34:26 +02:00
Allow configuring cookie attributes
I decided to put this in config.php because if cookie settings were to be stored in the database and configured via admin UI, entering incorrect settings could cause the admin session to be destroyed, requiring manual database intervention to fix. But it's a good prompt for discussion as to which kind of settings belong in config.php vs the database. Thoughts?
This commit is contained in:
@@ -22,13 +22,14 @@ use Zend\Stratigility\MiddlewareInterface;
|
||||
|
||||
class StartSession implements MiddlewareInterface
|
||||
{
|
||||
const COOKIE_NAME = 'session';
|
||||
|
||||
/**
|
||||
* @var CookieFactory
|
||||
*/
|
||||
protected $cookie;
|
||||
|
||||
/**
|
||||
* Rememberer constructor.
|
||||
* @param CookieFactory $cookie
|
||||
*/
|
||||
public function __construct(CookieFactory $cookie)
|
||||
@@ -56,7 +57,7 @@ class StartSession implements MiddlewareInterface
|
||||
{
|
||||
$session = new Session;
|
||||
|
||||
$session->setName('flarum_session');
|
||||
$session->setName($this->cookie->getName(self::COOKIE_NAME));
|
||||
$session->start();
|
||||
|
||||
if (! $session->has('csrf_token')) {
|
||||
@@ -79,7 +80,7 @@ class StartSession implements MiddlewareInterface
|
||||
{
|
||||
return FigResponseCookies::set(
|
||||
$response,
|
||||
$this->cookie->make($session->getName(), $session->getId())
|
||||
$this->cookie->make(self::COOKIE_NAME, $session->getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user