开发者

session / cookie issues codeigniter 1.7.2

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 开发者_C百科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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜