会话/ cookie问题codeigniter 1.7.2 [英] session / cookie issues codeigniter 1.7.2

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

问题描述

您好,我正在完成一个项目,突然遇到 CI 的问题。我正在运行版本1.7.2 ,我正在使用CI会话类来设置和获取会话数据。

Hi I’m finishing up a project and I’m suddenly having issues with CI. I’m running version 1.7.2 and I’m using the CI session class for setting and getting session data.

strong> Firefox和IE 。什么是weirder的应用程序只能在Chrome 中正常工作。我已经验证这是发生在应用程序的旧版本中,以前没有任何问题。

This happens in Firefox and IE. What’s weirder is the application only works properly in Chrome. I have verified that this is happening in older builds of the application too which didn’t have any issues previously.

这是我的配置:

会话

Session

$config['sess_cookie_name']        = 'ciprojectname';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'sessions';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 900; 

Cookie

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/"; 

我添加了cookie域,但问题仍然发生。我也读过,它可能是一个时间同步问题与服务器时间,但我已经尝试了在多个服务器。我想首先要看看为什么CI会在一个浏览器中工作,而不是其他浏览器。

I played with adding the cookie domain but the issue still happens. I’ve also read that it could be a time syncing issue with the server time but I’ve tried it on multiple servers. I guess the first thing to look at is why would CI would work in one browser and not others.

任何帮助将非常感激。

Any help would be greatly appreciated.

更新

我从未详细说明问题:

当我尝试访问/ controller /方法时,它会重新加载当前页面,什么也不做。有时如果我添加/ controller / method /< - 正斜杠,它会渲染下一页。

When I try to access /controller/method it'll reload the current page and do nothing. Sometimes if I add /controller/method/ <-- forward slash, it will render the next page.

推荐答案

是Firefox和IE正在重置加载之间的会话数据。在大多数情况下,这是由服务器设置引起的。我的猜测是在localhost上正常工作,并且现在有问题,一旦移动到远程服务器。

My guess is that Firefox and IE are resetting session data between loads. In most cases this is caused by server settings. My guess is it worked fine on localhost and is now having problems once moved to a remote server.

首先,找到问题。您必须准确找到问题发生的位置。一些建议:

First, find the problem. You must pinpoint exactly where the problem occurs. Some suggestions:


  1. 检查服务器日志以查看日期设置。是年份0000.如果所有服务器具有相同版本的PHP,那么这可能是您的问题。它是一些PHP版本的已知错误。 https://bugs.php.net/bug.php?id=48276

如果不是,数据库是否获取会话数据?如果是,那么您可以在从页面移动到页面时观察数据,以查看会话是否正在重置。

If no, is the Database getting the session data? If yes, then you can watch the data as you move from page to page to see if the session is being reset. If so, it is most likely a server settings issue.

如果没有,请检查您的浏览器安全设置。

If no, check your browser security settings. Once moved from localhost, there could be a security issue.

如果没有,请尝试从默认更改为 $ config ['sess_expiration' ] = 43200;

If no, try changing from default to $config[‘sess_expiration’] = 43200; Some recommend this to work when there is an issue with dropping sessions.

如果没有,请更改 sess_match_ip 更改为False,然后在Firefox和IE中尝试。

If no, Change sess_match_ip to False and Try it in Firefox and IE. It goes along with browser setting issues.

如果问题仍然不清楚,请进行缩小测试 - 重新创建问题所需的最低代码。创建具有setsession和readsession函数的单个控制器。请尝试在每个浏览器中重新加载页面,以查看会话是否续订。看看服务器日志和你的数据库。

If the problem is still not clear, usa a reduction test - the minimum code needed to recreate the problem. Create a single controller with a "setsession" and a "readsession" function. Try reloading the page in each browser to see if the session renews. Look at the server log and your database. If this works then the culprit would seem to be some data being sent in the session that the problem browsers do not like.



A。会话数据中的无效字符

A. An invalid character in session data

B。服务器时间设置

C。 IE和Firefox中的安全设置(如果服务器从localhost更改)

C. Security Settings in IE and Firefox (if the server changed from localhost)

D。 PHP中的日期错误问题

D. Problem with Date Bug in PHP

如果您仍然遇到问题,可能需要考虑使用本机会话库: http://codeigniter.com/wiki/Native_session/

If you are still having problems, it may be time to consider using the Native Session Library: http://codeigniter.com/wiki/Native_session/

看来这个问题因此流行的是某人为CI会话创建了自定义类: http://www.philsbury

It seems this problem is so prevalent that someone made a custom class for CI Sessions: http://www.philsbury.co.uk/blog/code-igniter-sessions it may be worth a shot.

希望这有帮助。

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

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