php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42040 cURL cookiejar resets default timezone to GMT
Submitted: 2007-07-19 04:26 UTC Modified: 2007-07-22 17:44 UTC
From: lkc at pobox dot sk Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.3 OS: Windows
Private report: No CVE-ID: None
 [2007-07-19 04:26 UTC] lkc at pobox dot sk
Description:
------------
Using cURL with COOKIEJAR option resets timezone setting to GMT.

This only occurs if:
1. The default timezone is set using date.timezone in php.ini, NOT through date_default_timezone_set().
2. The cookie file contains timestamp(s).


Reproduce code:
---------------
echo date_default_timezone_get(), "\n";

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
$f = curl_exec($ch);
curl_close($ch);

echo date_default_timezone_get(), "\n";


Expected result:
----------------
Show identical timezones.

Actual result:
--------------
Second timezone is always GMT.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-22 17:07 UTC] sfox@php.net
I can reproduce this under Windows XP. (It appears to be a Windows-only bug.)

Further info: The only way to reproduce this is if the timezone is set via the date.timezone setting in php.ini. The bug does NOT occur when the TZ env var is set via put_env(), nor when date_default_timezone_set() is called from the script. The workaround is to do either of those things before calling curl_setopt(CURLOPT_COOKIEJAR);.

Somehow DATEG(timezone) is being unset and the TZ env var populated with 'GMT', regardless of the timezone on the client.

The TZ env var is populated during libcurl configuration (tzset() is called after putenv('TZ=whatever')). That's the only place in the entire libcurl source it's used, given that the libcurl shipped with PHP doesn't have IDNA support. Neither tzset() nor putenv() is called in ext/curl.

At runtime, the TZ env var is only populated when CURLOPT_COOKIEJAR is set (not for CURLOPT_COOKIESESSION). I've no idea why, much less why setting TZ should interfere with PHP's global datetime values.
 [2007-07-22 17:39 UTC] derick@php.net
It's affecting it because the TZ env var takes priority over the date.timezone ini setting as can be read here:
http://no.php.net/manual/en/function.date-default-timezone-get.php

I'd say this is a curl bug, it should unset the env var when it's done with it.
 [2007-07-22 17:44 UTC] sfox@php.net
I agree with Derick - I had the priorities confused when I was looking at src, but this makes perfect sense.

Passing the bug on to the libcurl team and 'bogusifying' this report - it's a bug, Jim, but not as we know it.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC