Search code examples
phpcookiescurllibcurlhttpcookie

Generate and save a custom cookie on the serverside


I would like to generate a cookie (on the server side so there won't be any browser) with specific name/values and save it in a text file (e.g with fopen ). Later I'm planning to to use that cookie with cURL . The problem is that I don't understand what's the cookie format and how should I save it . When I look on the cookies saved by cURL I have something like this

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.example.com   FALSE   /       FALSE   0       ASP.NET_SessionId       3ddldk5iccxrj45fsl2ctrd
www.example.com   FALSE   /       FALSE   32522347      sccouscIX       548913113

I don't understand the spaces and what method I should use to generate a working cookie . As proof of concept I would like to generate a simple cookie with name : exampleId and value 000000000

exampleId   000000000   /   www.example.org

Update just to make sure the question is understood: I need to generate a custom cookie not to get one with cURL generated by other websites. I also found the Original Netscape cookie specification on curl website


Solution

  • http://xiix.wordpress.com/2006/03/23/mozillafirefox-cookie-format/