有人可以向我解释 session 驱动程序吗?对“laravel session 驱动程序”的搜索没有显示任何有关不同类型的信息。我问这个问题是因为以下教程建议使用 REST API 的数组驱动程序,但我不知道为什么。教程:https://speakerdeck.com/akuzemchak/simple-api-development-with-laravel?slide=62
这是 app/config/session.php 中的相关部分
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "native", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => 'native',
最佳答案
这很容易。驱动程序定义 session 数据的存储位置。
native
- session 将由内部 PHP 程序处理cookie
- session 将存储在 cookie 中数据库
- session 将存储在数据库中(默认情况下存储在表sessions
中)memcached
/redis
- 使用此守护进程之一作为 session 存储array
- session 将存储在普通数组中(由 MockArraySessionStorage 处理)
array
驱动程序意味着 session 仅针对每个请求(在 PHP 运行时存储),之后它就会消失:)
关于Laravel session 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17070851/