1
0
mirror of https://github.com/flarum/core.git synced 2025-10-14 16:34:26 +02:00
Files
php-flarum/src/Http/SessionAuthenticator.php
Toby Zerner 5672819549 Use Illuminate Session component instead of Symfony
Symfony's component relies on PHP's native session functionality, which
is not ideal. It automatically sets its own cookie headers, resulting in
this issue: https://github.com/flarum/core/issues/1084#issuecomment-364569953

The Illuminate component is more powerful and has a simpler API for
extension with other drivers and such, and fits in nicely with other
components we use (the majority of which are from Illuminate).
2018-03-18 14:43:44 +01:00

37 lines
712 B
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Http;
use Illuminate\Contracts\Session\Session;
class SessionAuthenticator
{
/**
* @param Session $session
* @param int $userId
*/
public function logIn(Session $session, $userId)
{
$session->regenerate(true);
$session->put('user_id', $userId);
}
/**
* @param Session $session
*/
public function logOut(Session $session)
{
$session->invalidate();
$session->regenerateToken();
}
}