2016-08-28 10:05:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2016-08-29 22:46:57 +08:00
|
|
|
use Closure;
|
|
|
|
use Session;
|
2016-08-28 10:05:21 +08:00
|
|
|
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
|
|
|
|
|
|
|
class EncryptCookies extends BaseEncrypter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The names of the cookies that should not be encrypted.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $except = [
|
2016-09-24 22:49:20 +08:00
|
|
|
'locale'
|
2016-08-28 10:05:21 +08:00
|
|
|
];
|
2016-08-29 22:46:57 +08:00
|
|
|
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
|
|
|
|
Session::put('uid' , $_COOKIE['uid']);
|
|
|
|
Session::put('token', $_COOKIE['token']);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::handle($request, $next);
|
|
|
|
}
|
2016-08-28 10:05:21 +08:00
|
|
|
}
|