You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP cookie headers are actually quite tricky to parse, because the expiry date often contains a comma, and commas are supposed to be the delimiter between individual cookies.
This parser cheats by splitting the cookie header based on the equals sign, and reconstructing the key pairs in a loop.
This sample code doesn't support all cookie properties, but it ought to be trivial to add more. It hasn't been tested a great deal, so use at your own risk.
I originally wrote this in Objective-C for ASIHTTPRequest (http://allseeing-i.com/asi-http-request) before I discovered Apple's function that does this for you (DOH!), but I'd guess this PHP port is likely to be more useful to more people. Even if you hate PHP with a passion, you ought to be able to read it well enough to port it to whatever language you like.