【问题标题】:How do I configure the session in my cakephp application?如何在我的 cakephp 应用程序中配置会话?
【发布时间】:2019-09-23 12:48:25
【问题描述】:

我正在尝试为我的应用程序的会话创建一个端点。我遵循https://book.cakephp.org/3.0/en/development/sessions.html 中的所有步骤 但不工作。

我在我的数据库中创建了名为 session 的表,并在 src/Http/Session/ComboSession.php 中创建了 ComboSession,并按照 cakephp 文档的建议更改了 app.php 中的配置。

'Session' => [
    'defaults' => 'database',
    'handler' => [
        'engine' => 'ComboSession',
        'model' => 'session',
        'cache' => 'apc'
    ]
],
'Cache' => [
    'apc' => ['engine' => 'Apc']
]

我也试过这个:

'Cache' => [
    'apc' => ['engine' => 'Apcu']
]

我的错误信息:缓存引擎 Cake\Cache\Engine\ApcuEngine 配置不正确。

【问题讨论】:

  • 你的缓存配置看起来不像what's documentedengine 键仅用于会话配置,缓存配置中类似的东西是className
  • 感谢您的帮助 Greg Schmidt。我将缓存的配置更改为使用默认值并正常工作。

标签: session cakephp


【解决方案1】:

我的灵魂:

'Session' => [
    'defaults' => 'database',
    'handler' => [
        'engine' => 'ComboSession',
        'model' => 'sessions',
        'cache' => 'defaults'
    ]
],

'Cache' => [
    'defaults' => [
        'className' => 'Cake\Cache\Engine\FileEngine',
        'path' => CACHE,
        'url' => env('CACHE_DEFAULT_URL', null),
    ],

【讨论】:

    猜你喜欢
    • 2011-03-12
    • 1970-01-01
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    相关资源
    最近更新 更多