I'd like to be able to add cookies set from javascript into the cookie jar. Is there any PHP functions for this? or should i just open the cookie jar using fopen and hijack it?
As others suggested, in order to add cookies you have to add the cookie to the cookieFile mentioned in the cookie jar curl property.
file_put_contents($cookie, ".ebay.com TRUE / FALSE 0 lucky9 ".$lucky9, FILE_APPEND | LOCK_EX,null);
Above is something I did to insert a cookie into my cookieFile.
The cookieFile contains a cookie in 7 tab delimited properties :
domain - The domain that created AND that can read the variable.
flag - A TRUE/FALSE value indicating if all machines within a given domain can access
the variable. This value is set automatically by the browser, depending on the value you set
for domain.
path - The path within the domain that the variable is valid for.
secure - A TRUE/FALSE value indicating if a secure connection with the domain is needed to access the variable.
expiration - The UNIX time that the variable will expire on. UNIX time is defined as the number of seconds since Jan 1, 1970 00:00:00 GMT.
name - The name of the variable.
value - The value of the variable.
Taken from here.
Shameless plug:
You may use Cookie Jar Writer.
It is an utility PHP class for runtime editing cURL's cookie jar file. In other words, it allows to add custom cookie variables to a cookie jar file within sequence of cURL requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With