从 ssl 移动到非 ssl 时会话未保存

Session not saving when moving from ssl to non-ssl(从 ssl 移动到非 ssl 时会话未保存)
本文介绍了从 ssl 移动到非 ssl 时会话未保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个登录屏幕,我强制将其设为 ssl,如下所示:https://www.foobar.com/login然后在他们登录后,他们被移动到主页:https://www.foobar.com/dashbaord

I have a login screen that I force to be ssl, so like this: https://www.foobar.com/login then after they login, they get moved to the homepage: https://www.foobar.com/dashbaord

但是,我想在登录后将人们从 SSL 中移除(以节省 CPU),因此在检查他们实际上已登录 https://www.foobar.com/dashbaord 我把它们移到http://www.foobar.com/dashbaord

However, I want to move people off of SSL once logged in (to save CPU), so just after checking that they are in fact logged in on https://www.foobar.com/dashbaord I move them to http://www.foobar.com/dashbaord

这似乎总是会清除会话变量,因为当页面再次运行时,它确认它们已登录(就像所有页面一样)并且会话似乎不存在,因此它将它们移动到登录屏幕.

Well this always seems to wipe out the session variables, because when the page runs again, it confirms they are logged in (as all pages do) and session appears not to exist, so it moves them to the login screen.

奇怪/发现:

  1. 列表项
  2. 第二次登录总是有效,并且很高兴让我访问 http://www.foobar.com/dashbaord
  3. 第一次登录成功创建了一个cookie
  4. 如果我登录两次,然后注销,然后再次登录,我不需要两次登录(我似乎已经将其追溯到 cookie 存在的事实).如果我删除 cookie,我将返回两次登录.
  5. 第二次登录后,我可以从非 ssl 从 ssl 移动,会话仍然存在.
  6. 在第一次登录时,移动到非 ssl 站点会完全清除会话,手动返回 ssl 站点仍然迫使我再次登录.
  7. 第二次登录使用与第一次完全相同的机制,通过 ssl

我尝试了什么:

  1. 使用 Cake 的 security.level 和 session.checkagent 设置 - 什么都没有
  2. 让 cake 将会话存储在 db(而不是文件系统)中 - 什么都没有
  3. 在 XP 机器上测试 FF、IE、Chrome.

所以我觉得这与正在创建但未被读取的cookie有关.

So I feel like this is something related to the cookie being created but not being read.

环境:1. Debian2. 阿帕奇 23. mysql 44. PHP 55. CakePHP6.会话被PHP默认保存为文件

Environment: 1. Debian 2. Apache 2 3. Mysql 4 4. PHP 5 5. CakePHP 6. Sessions are being saved PHP default, as files

推荐答案

我想通了.Cake 在 SSL 连接下自动切换 session.cookie_secure ini 值,因此创建的 cookie 是安全 cookie,第二个页面无法识别.

I figured this out. Cake was switching the session.cookie_secure ini value on-the-fly while under SSL connections automatically, So the cookie being created was a secure cookie, which the second page wouldn't recognize.

解决办法,注释掉/cake/lib/session.php第420行ish:

Solution, comment out /cake/lib/session.php line 420 ish:

ini_set('session.cookie_secure', 1);

ini_set('session.cookie_secure', 1);

(只需搜索即可找到它,因为我确定 # 行会随着版本的发布而更改.)

(Just search for that to find it, as I'm sure the line # will change as releases come out.)

这篇关于从 ssl 移动到非 ssl 时会话未保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)