【问题标题】:Laravel 4 Sessions Not persisting with PHP 5.3Laravel 4 会话不坚持 PHP 5.3
【发布时间】:2014-04-29 10:28:48
【问题描述】:

我在整个网络上都看到过类似的问题,但没有任何修复的运气。我在本地安装了 laravel 4,我的会话效果很好。我可以使用...登录。

Auth::login($user,true);

然后用...检查登录的用户

Auth::check()

但是我发现,一旦我推送到运行 PHP 5.3 会话的生产环境就不再工作了。为了测试,我尝试根据其他文章的建议手动设置会话变量,并在其他调用中回显它。再次在本地工作,而不是在产品上。有没有人处理过这个问题?

谢谢

【问题讨论】:

  • 您的本地开发环境是否与 PHP 5.3 不同?你们各自开发和生产的php.ini文件有区别吗?
  • 抱歉重要信息 - 我的本地开发环境是 5.4
  • 忘记授权。 Session::put('foo','bar') 是否仍然存在?
  • 我无法访问我设置的任何会话变量。

标签: php session laravel


【解决方案1】:

您是否检查过生产服务器上的会话保存路径并确保其可写。还要确保 app/storage 目录已被 chmoded 777。

要检查的相关文件是 php.ini

[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = files

; Argument passed to save_handler.  In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.

;
; The path can be defined as:
;
;     session.save_path = "N;/path"
;
; where N is an integer.  Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories.  This is useful if
; your OS has problems with many files in one directory, and is
; a more efficient layout for servers that handle many sessions.

和/app/config/sessions.php

/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/

'files' => storage_path().'/sessions',

/*

它可能再次指向存储文件夹。我会确保 777 是可写的,这可能会解决您的问题。

【讨论】:

    猜你喜欢
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    相关资源
    最近更新 更多