Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookie Corruption on Mobile Network

I am using Codeigniter 2.1 on one of my latest sites and when accessed over 3g, cookies are becoming corrupt...

When doing some debugging to the point where the cookie is initially read I can see that it's obviously truncated, heres an example:

a:14:{ 

Should be

a:14:{s:10:"session_id";s:32:"ef171f95db26ad51986.......

This only happens when a cookie is read on a device connected to a mobile network, I've only been able to test three so far and to my surprise, one worked:

  • Asus Laptop w/ Vodafone Dongle (x)
  • Macbook Air w/ Vodafone Dongle (x)
  • iPhone 3 on Orange UK network (x)
  • Samsung Galaxy SII on Three (Worked)

I'm guessing its network based and the header is being corrupted somewhere along the way. ( Possibly a proxy? )

This has been getting to me all week so any information would be awesome.

Edit: To note, the site has quite a few cookies but not large in size. We have Google Analytics, Sharethis, Uservoice and Facebook.

like image 980
Eddie Avatar asked Oct 08 '22 23:10

Eddie


1 Answers

While I do not know what might be causing this, I have a few ideas for you which may help you find the issue which should help you to work around it. What I would do first is try to make the error consistent try just the one provider with the example above.

  • is the cookie ALWAYS equal to a:14:{
  • can you create a 2 line PHP page with only a cookie named the same as that cookie, print_r the cookie on line 1 and set the cookie on line 2. And then change the value of the cookie to see what kind of change you can make when there are no other variables on the page. (can you set the cookie to a:14:{}? a:1? a:14:xxx:{xxxx}? We are looking for a pattern that might consistently be cutting of the string.
  • if the 2 line page does not have a problem cutting of the code then take a copy of the page that you are having the actual problem on , and start deleting EVERYTHING on the page until you only have two lines (the line that sets the cookie and the line that prints it) The problem is somewhere in your code.
  • if the 2 line page DOES have the problem then perhaps it really is the mobile networks (in my experience I have not see this, however they could have some sort of a PROXY that is cleaning the cookies). I would start trying to send different code through the cookie until you find something that did not have a problem on the provider network. (such as uuencode or base64_encode the data in the cookie).
  • If it turns out that the providers block everything, perhaps consider downloading a program such as fiddler which allows you to analyze at a very low level the headers that are sent back and forth.

Hope these troubleshooting steps help.

like image 115
Michael Blood Avatar answered Oct 12 '22 12:10

Michael Blood