Welcome Guest, Not a member yet? Register   Sign In
[Solved] CI Sessions in IE compatibility mode
#1

[eluser]Adrian Walls[/eluser]
Hi,

I have a website which integrates with PayPal Express Checkout. So when a user clicks submit to purchase something they are re-directed to the PayPal website where their payment is processed and after which they are re-directed back to my website.

This works OK in virtually all browsers except we have been getting quite a few complaints that customers are experiencing an error in certain circumstances. After adding additional logging into the website we noticed this only affected customers running IE in compatibility mode and that when they returned back to our website from PayPal all session data was completely empty. What has actually happened is that CI has started a new session, which was obviously minus the session data I added before going off to PayPal.

I am storing CI sessions in the database and the following session setting are set in my config.php file:

Code:
$config['sess_cookie_name']    = 'ci_session';
$config['sess_expiration']    = 7200;
$config['sess_expire_on_close']    = TRUE;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']    = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;

I've debugged through this in all browsers including IE (not in compatibility mode) completely clearing out the session table each time and I can see that in all cases there is only ever one row in the table for the duration of the transaction from the site to PayPal and back, which is exactly what I would expect. However when running IE in compatibility mode the handle to the session is gone after coming back from PayPal because it has started a new session in the database, so we have two rows present.

I thought if I passed the session id across to PayPal in the return URL, on coming back to the site I would check if the session data I was expecting was empty and if so lookup the database with this session id so I could retrieve the info needed and populate it back into the current session. This works to some extent in that when user comes back from PayPal they are still logged in, still showing user login session details, etc... However it then appears that if I click on a subsequent link on the site the session info is gone on this subsequent page load and I can now see a third session row in the sessions table. Compatibility mode appears to spawn new sessions but I don't understand how or why.

So the problem really is how can I deal with this session switching in IE compatibility mode and is there something I am just missing. Has anyone else had a similar experience in the past?

BTW....Am using CI 2.0.1.
#2

[eluser]pickupman[/eluser]
Got to love IE right? I have had similar issues, as everyone else. IE is really picky about the timestamp of the cookie. If you sess_expiration is less than the time difference between your system clock and the server time, you will lose sessions in IE. So let's say a users clock is not properly set, or you are more than 2 hours between the server timezone and your computer, this problem will exist.

I would first start with extending the session_expiration to something much longer (ie. 1 day = 86400). Maybe even increase sess_time_to_update.
#3

[eluser]Mainboard[/eluser]
i think that you need to put in your html code, some meta for compatibility with your ie brower, in this case you can to put this one
Code:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
this meta is for IE 8
#4

[eluser]Adrian Walls[/eluser]
Thanks for the replies. IE is a complete pain in the ***.

I have tried extending the session_expiration as suggested but to no avail. It's still creating 3 different sessions when in compatibility mode compared to the single session maintained where when it's not in either IE7, IE8 or IE9 normally.

Have also tried to force IE into compatibility mode using:

Code:
<meta http-equiv="X-UA-Compatible" content="IE=8" />

But still no joy. Each time I return back from the PayPal website I can see a new session has been created in the database and I've lost all the info in the session before I left to go to PayPal. Again this is working OK in IE7, IE8 & IE9 normally.

Really tearing my hair out with this one.
#5

[eluser]LuckyFella73[/eluser]
Hi Wallzy,

did you try to remove the underscore in cookie name?
Code:
$config['sess_cookie_name']    = 'cisession';

I just know that using an underscore in cookie names
can be problematic when using IE. Maybe that's not
the problem in your case but you can try ...
#6

[eluser]Adrian Walls[/eluser]
Hi,

Tried removing the underscore in the cookie name but still no joy. Still multiple CI sessions being spawned when in compatibility mode and breaking my session Sad
#7

[eluser]pickupman[/eluser]
Try setting match user agent to FALSE
#8

[eluser]Adrian Walls[/eluser]
Setting this to false appears to have done the trick :-) I swore I have tried this is the past but I have tried so many combinations I can't be sure I that this exact one.

Cheers for the assistance guys. Much appreciated.
#9

[eluser]pickupman[/eluser]
Glad you got it working. I remember that working for me recently, because for some reason the User agent shows up slightly different in the sessions table.
#10

[eluser]Adrian Walls[/eluser]
Yeah, makes sense when you think about it as IE is switching the User Agent to identify the browser is in compatibility mode and if CI is matching on this then it is going to be different and therefore it will spawn a new session.




Theme © iAndrew 2016 - Forum software by © MyBB