Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bake_cookies($dest, $src){
- //covert JSON cookie file (src) to Netscape cookie file (dest)
- $cookie_json = json_decode(preg_replace('/^#.*\n/', '', file_get_contents($src))); //get cookie json contents, strip #-style comments, decode
- $netscape_cookie = ''; //build netscape cookie contents
- foreach($cookie_json as $cookie){
- $secure_flag = ($cookie->secure) ? 'TRUE' : 'FALSE';
- $expiration = 0;
- if(isSet($cookie->expirationDate)){
- $expiration = round($cookie->expirationDate);
- }
- $netscape_cookie .= "{$cookie->domain}\tFALSE\t{$cookie->path}\t{$secure_flag}\t{$expiration}\t{$cookie->name}\t{$cookie->value}\n";
- }
- file_put_contents($dest, $netscape_cookie); //create netscape cookie using accumulated cookies
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement