Homestead 4.2中的会话问题 [英] Session issues in Homestead 4.2

查看:67
本文介绍了Homestead 4.2中的会话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Laravel Homestead 用于我的PHP开发,并且正在一个广泛使用Sessions的项目中工作.

I am using Laravel Homestead for my php development and working on a project that uses Sessions extensively.

我注意到会话根本不会持续.我怎样才能解决这个问题?

I've noticed that sessions do not persist at all. How can I fix this?

示例:

这是Index.php

here's Index.php

    <?php

session_start();
$_SESSION['variable'] = 'This Variable';
?>
<html>
<body>
<h1>
<?php
echo $_SESSION['variable'];

?>
</h1>

</body>
</html>

这是sessionCheck.php

Here's sessionCheck.php

<html>
<body>
<h1>
    <?php
    session_start();
    print_r($_SESSION);

    ?>
</h1>

</body>
</html>

回显空数组.

推荐答案

Php会话路径没有正确的权限,因此出现了问题.

Php sessions path did not have the right permissions, hence the the issue.

对于宅基地,ssh并将正确的权限设置为:

For homestead, ssh and set the correct permissions as:

sudo chmod 777 /var/lib/php/sessions 

要检查会话路径,请使用 phpinfo();

To check your sessions path, use phpinfo();

这篇关于Homestead 4.2中的会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆