472,958 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

server time vs browser time on cookie expirations

Say,

I want to set a cookie and have it expire an hour after it's set. It's
looking like this is only possible for browsers which are in the same time
zone as my server??

In other words, if I set my cookie with:

setcookie('CookieName', $SomeValue, time()+3600, "/");

the cookie should expire 1 hr later. But time() returns the time as it is at
the location of the server. If whoever loads my page is 3 timezones east of
where my server is, the time that I set is already expired as far as that
browser is concerned!

Is this correct or am I completely nuts?

If it is correct, is there any way I can set a cookie based on the browser
machine's time clock, so it will work the way I want no matter where the
browser is located relative to the server?

-dg
Jul 16 '05 #1
4 11548
Cookies can be evil at times :)

Two facts:

1. The only legal timezone allowed for a cookie is GMT, no matter where
the server lives.
2. time() returns the number of seconds since 01/01/1970 00:00:00 GMT.

Now, I've not done any tests, but I belive that the browser itself will
determine what timezone it is in and will decide on whether to purge the
cookie -after- converting from GMT to its own timezone.

So, I believe that you're safe doing what you are doing and you
shouldn't worry about timezones.

Here's Netscape's cookies specification:
http://wp.netscape.com/newsref/std/cookie_spec.html

MK.

dan glenn wrote:
Say,

I want to set a cookie and have it expire an hour after it's set. It's
looking like this is only possible for browsers which are in the same time
zone as my server??

In other words, if I set my cookie with:

setcookie('CookieName', $SomeValue, time()+3600, "/");

the cookie should expire 1 hr later. But time() returns the time as it is at
the location of the server. If whoever loads my page is 3 timezones east of
where my server is, the time that I set is already expired as far as that
browser is concerned!

Is this correct or am I completely nuts?

If it is correct, is there any way I can set a cookie based on the browser
machine's time clock, so it will work the way I want no matter where the
browser is located relative to the server?

-dg


--
MeerKat

Jul 16 '05 #2
Oh, and I forgot to add that this assumes that the client has their
clock set correctly and set to the correct timezone...

MeerKat wrote:
Cookies can be evil at times :)

Two facts:

1. The only legal timezone allowed for a cookie is GMT, no matter where
the server lives.
2. time() returns the number of seconds since 01/01/1970 00:00:00 GMT.

Now, I've not done any tests, but I belive that the browser itself will
determine what timezone it is in and will decide on whether to purge the
cookie -after- converting from GMT to its own timezone.

So, I believe that you're safe doing what you are doing and you
shouldn't worry about timezones.

Here's Netscape's cookies specification:
http://wp.netscape.com/newsref/std/cookie_spec.html

MK.

dan glenn wrote:
Say,

I want to set a cookie and have it expire an hour after it's set. It's
looking like this is only possible for browsers which are in the same
time
zone as my server??

In other words, if I set my cookie with:

setcookie('CookieName', $SomeValue, time()+3600, "/");

the cookie should expire 1 hr later. But time() returns the time as it
is at
the location of the server. If whoever loads my page is 3 timezones
east of
where my server is, the time that I set is already expired as far as that
browser is concerned!

Is this correct or am I completely nuts?

If it is correct, is there any way I can set a cookie based on the
browser
machine's time clock, so it will work the way I want no matter where the
browser is located relative to the server?

-dg


--
MeerKat

Jul 16 '05 #3
MeerKat - If what you say is true (that time() returns a GMS timestamp and
not a timestamp that is the servers own timezone time), then it must follow
that the date() function must do an automatic timezone conversion to local
time. For when I do an

echo date("l dS of F Y h:i:s A",time());

on my localhost, I get exactly my current local timezone time, NOT GMT. But
I don't see any mention of this auto-conversion to local time zone
functionality in the DATE() function documentation.

Certainly time() DOES return the GMS timestamp - I don't doubt that. It's
just that I've been using examples of the above on my localhost and 3-hr
different timezone server and had it firmly in my mind that time() was
reporting local server time because those were the times I was getting,
under the date() transformation.

My php manual states, under date():

Returns a string formatted according to the given format string using the
given integer timestamp or the current local time if no timestamp is given.

The phrase "or the current local time if no timestamp is given" implies to
me that when a timestamp IS given, it would just report the GMS time, since
that's what a 'real' timestamp is. But it doesn't, evidently. It takes a GMS
timestamp and reports local time. Is this your understanding?

thanks,
dg

"MeerKat" <li****************@blueyonder.co.uk> wrote in message
news:KA*****************@news-binary.blueyonder.co.uk...
Cookies can be evil at times :)

Two facts:

1. The only legal timezone allowed for a cookie is GMT, no matter where
the server lives.
2. time() returns the number of seconds since 01/01/1970 00:00:00 GMT.

Now, I've not done any tests, but I belive that the browser itself will
determine what timezone it is in and will decide on whether to purge the
cookie -after- converting from GMT to its own timezone.

So, I believe that you're safe doing what you are doing and you
shouldn't worry about timezones.

Here's Netscape's cookies specification:
http://wp.netscape.com/newsref/std/cookie_spec.html

MK.

dan glenn wrote:
Say,

I want to set a cookie and have it expire an hour after it's set. It's
looking like this is only possible for browsers which are in the same time zone as my server??

In other words, if I set my cookie with:

setcookie('CookieName', $SomeValue, time()+3600, "/");

the cookie should expire 1 hr later. But time() returns the time as it is at the location of the server. If whoever loads my page is 3 timezones east of where my server is, the time that I set is already expired as far as that browser is concerned!

Is this correct or am I completely nuts?

If it is correct, is there any way I can set a cookie based on the browser machine's time clock, so it will work the way I want no matter where the
browser is located relative to the server?

-dg


--
MeerKat

Jul 16 '05 #4
On Sat, 09 Aug 2003 15:49:40 -0500, in message
<E7***************@newssvr25.news.prodigy.com>,"da n glenn"
<da********@yahoo.com> wrote:
I want to set a cookie and have it expire an hour after it's set.
[...] But time() returns the time as it
is at the location of the server. If whoever loads my page is 3
timezones east of where my server is, the time that I set is already
expired as far as that browser is concerned!


It's not a problem because the cookie's expire
time is sent as text, not a unix time value,
and the cookie is in GMT, for example:

HTTP/1.1 200 OK
Date: Sun, 10 Aug 2003 01:41:51 GMT
Set-Cookie: cookie[one]=cookieone; expires=Sun, 10-Aug-03 01:51:51 GMT
Connection: close
Content-Type: text/html
Content-Language: en

Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nigo | last post by:
Hi there Is it posible to make a link (to a php-file on a server) in an email that, when you click on it, sends info about who the reciver of the email is? Lets say I send out an email thru...
6
by: Rob Meade | last post by:
Hi all, At work we have 2 servers in a cluster for our web apps. One problem we have experienced (along with many others!) - is that if a user is logged into one of the applications on server...
15
by: Oleg Leikin | last post by:
Hi, (newbie question) I've created some simple .NET ASP application that should store cookies at the client machine. According to the documentation cookie expiration time is set via...
0
by: Bill Borg | last post by:
Hello all, I've read through the posts out here, mostly get it, but am still trying to understand the relationship among the ticket, the cookie, and their expirations. I understand that the...
6
by: Andre Ranieri | last post by:
I'm trying to create a login page for customers to log into our corporate website, our presidents naturally wants the user and password fields to populate from a cookie so the customer doesn't have...
2
by: junOnline | last post by:
Hi, I am developing an asp.net 2.0 application using visual studio 2005 on my computer and I am getting very inconsistent results when I test on my computer versus from other computers. The...
2
by: HopfZ | last post by:
Server sends cookie to browser and the browser send the same cookie back to the server according to Wikipedia. Do browsers send even javascript-generated cookie to servers? For example, if I...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am thinking about doing this since I got several cases that some of our internal users open more than one browser at the same time from our server. When one of the transactions was not...
4
by: rodmc | last post by:
Hi, I am trying to set a cookie on a client computer using the Cookie module however all I get is the text being printed in the browser window. Can anyone point me in the right direction so that...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.