Internet Explorer (11) return different user agent

2019-07-30 01:35发布

问题:

I am implementing a payment system where by the card details are posted to the gateway page which transparently redirect the user back to my site. My session verifies the User Agent to make sure they are the same in each request. This works fine in both Chrome and FF, however in IE, user agent send is different on the transparent redirect.

Request 1. An Ajax request to setup the payment data. User Agent is Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko

Request 2. Transparent redirect coming back from gatway. (GET Request) Agent is Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)

Which basically breaks my session as it's taken as a new session now that the agent is changed. I can easily switch off user agent checking, but I'd like to keep that. Any idea what's going on?

回答1:

I'd advise against the user-agent check. In my own projects we usually generate a token which we store in the session and include it in the redirect URL. When your user comes back you can compare that with what's stored in your session.



回答2:

make sure you are forcing user to use IE in same mode paypal suggests.

my answer from similar question:

TokenMismatch ONLY Certain Browsers - Laravel 5 Fresh/Production

"the source of the problem could be compatibility mode of IE and different sessions of those modes using.

Can you try it with adding this line on top of the get and post pages:

header("X-UA-Compatible: IE=Edge");"