会话/cookie 问题 codeigniter 1.7.2

发布于 2024-11-26 02:27:48 字数 1121 浏览 0 评论 0原文

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

这种情况发生在 Firefox 和 IE 中。更奇怪的是该应用程序只能在 Chrome 中正常运行。我已经证实这种情况也发生在应用程序的旧版本中,以前没有任何问题。

这是我的配置:

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; 

Cookies

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

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

任何帮助将不胜感激。

更新

我从未详细描述过这个问题:

当我尝试访问 /controller/method 时,它会重新加载当前页面并且不执行任何操作。有时,如果我添加 /controller/method/ <-- 正斜杠,它将呈现下一页。

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.

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.

Here’s my config:

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; 

Cookies

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

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.

Update

I never described the issue in detail:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月野兔 2024-12-03 02:27:48

我的猜测是 Firefox 和 IE 正在重置加载之间的会话数据。在大多数情况下,这是由服务器设置引起的。我的猜测是它在本地主机上运行良好,但现在一旦移动到远程服务器就会出现问题。

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

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

  2. 如果不是,数据库是否正在获取会话数据?如果是,那么您可以在从一个页面移动到另一个页面时观察数据,以查看会话是否正在重置。如果是这样,很可能是服务器设置问题。

  3. 如果没有,请检查您的浏览器安全设置。从本地主机移出后,可能会出现安全问题。

  4. 如果没有,请尝试将默认值更改为 $config['sess_expiration'] = 43200; 有些人建议在出现删除会话问题时使用此方法。

  5. 如果不是,请将 sess_match_ip 更改为 False 并在 Firefox 和 IE 中尝试。这与浏览器设置问题有关。

  6. 如果问题仍然不清楚,请使用缩减测试 - 重现问题所需的最少代码。创建一个具有“setsession”和“readsession”函数的单个控制器。尝试在每个浏览器中重新加载页面以查看会话是否更新。查看服务器日志和数据库。如果这有效,那么罪魁祸首似乎是问题浏览器不喜欢的会话中发送的一些数据。

根本问题很可能是以下一项或多项:

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

B. 服务器时间设置

C. IE 和 Firefox 中的安全设置(如果服务器从本地主机更改)

D. PHP 中的日期错误问题

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

看来这个问题非常普遍,以至于有人为 CI 会话制作了一个自定义类: philsbury.co.uk/blog/code-igniter-sessions" rel="nofollow">http://www.philsbury.co.uk/blog/code-igniter-sessions 也许值得一试。

希望这有帮助。

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. Check server log to see how date is being set. Is the Year 0000. If all servers have the same version of PHP then this could be your problem. It is a known bug for some PHP versions. https://bugs.php.net/bug.php?id=48276

  2. 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.

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

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

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

  6. 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.

The underlying issue is most likely one or more of the following:

A. An invalid character in session data

B. Server Time Settings

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

D. Problem with Date Bug in PHP

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

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.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文