473,811 Members | 3,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cookie expiring problems

I am using the following code to set a cookie for 30 seconds:
$value = $_GET[submit_enter];
if (! isset($_COOKIE['testit'])){
setcookie('test it',$value,time ()+30,'/');
}
What happens:
1. On the windows apache server the cookie disappears after 30 seconds
2. On the linux apache server the cookie disappears after hours????

Fact is: Servertime is localtime

Questions:
1. Does anyone know about this problem on a linux machine?
2. Do we really need the time() to set a cookie?
3. Is there a special configuration to be done (php.ini or somewhere else)?

Thank you for your help
Stefan
Jul 17 '05 #1
1 1900
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefan wrote:
I am using the following code to set a cookie for 30 seconds: [clip]

Setting cookies with a short[1] lifetime is not reliable. The
reason for this is simple: The cookie expiry time is an absolute
value, not a delta, and this time is set by the server but
evaluated by the client. As a result if the clients clock is 29 seconds
ahead of the servers clock, and the server sends a cookie with a
30 second lifetime, the cookie only lives for 1 second.
What happens:
1. On the windows apache server the cookie disappears after 30 seconds
2. On the linux apache server the cookie disappears after hours????


This could (and probably is) caused by the server and client clocks
beeing out of sync and/or timezone related issues.

If you need short lived cookies, you'll have to include the
expiry time in the cookies *value*, and check it server side.
Bob

[1] The shorter the time, the lower the reliability. I'd say
anything less then a week is likely to get you into trouble
on a regular basis.

- --
| B. Johannessen <bo*@db.org> +47 97 15 20 09 - http://db.org/
| Mail & Spam - News, Drafts & Standards - http://db.org/blog/
| On The Origin Of Spam; Spam Statistics - http://db.org/spam/
- --
-----BEGIN PGP SIGNATURE-----

iD8DBQFANErtooi sUyMOFlgRAllbAJ 0VZQoYBkUbSzoy7 3fuwH2I0eMq0QCe Pcb1
a06yMkT4fjGOtSG goxqAIwQ=
=WAhe
-----END PGP SIGNATURE-----
Jul 17 '05 #2

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

Similar topics

1
1742
by: HorseGeek | last post by:
I have three servers: Server1, Server2, and Server3. There is a login cookie does not expire for SOME users on Server2. Ironically, the login cookie expires correctly for ALL users on the Server1 and Server3 websites. This seems to imply a problem with the user's browser settings ... except the users that have consistent problems with the Server2 are able to read the logon cookie and other cookies which control navigation to the...
7
7226
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local time reaches the set expire-time. But if it is an expire time set on my server in California, and the cookie is put on a computer that is running on London Time, and the expire time is set at the server as 20 minutes from now, the London computer...
3
2366
by: Mike | last post by:
I have a web application that the forms authentication cookie is not expiring correctly. When I look at the trace information of a newly requested page after the session and forms authentication have expired the forms authentication cookie is assigned a new value. I am never redirected to the login page after my initial login. If I access the site from http://localhost/myapp instead of myapp.domain.com the cookies expire correctly. The cookie...
1
1328
by: Charlie | last post by:
Hi: Our portal writes a cookie to browser on login. The cookie is then requested by applications launched by portal as a way of passing credentials. The problem is when logging off portal, then logging back in as another person, cookie retrieved by application belongs to first user who is now logged out. Portal is correctly adding and removing cookies on login and logout so it appears the old cookie is being kept in memory somewhere...
15
2153
by: Edwin Knoppert | last post by:
I have searched but info is limitted. In my test app i used a non persistant cookie for forms authentication. slidingExpiration is set to true On run and close and rerun the login remains ok. I have a time-out of one minute and indeed, it directs me to the login if i wait to long. The slidingExpiration does it's work also.
7
2049
by: Adam Bates | last post by:
Hello, I have a problem, I have been using Cookie Authentication on the 1.1 framework for around 3 months, when I moved the site internally within my hosting company from a server with 1.1 framework to a server with 2.0 framework I have had cookie expiring problems. Since moving to the 2.0 server, the cookies now expire within 24 hours at the most. I have checked that the cookie has a expiry date in the future, which it does (6 years...
0
1740
by: robert | last post by:
I have noticed in .net 2 that when authenticating a user, setting the cookie using either redirectfromloginpage or setauthcookie, specifying true for the persistent parameter that the cookie is persistent with an expiry time of 30 minutes from now, unless you have specified a timeout attribute in the forms element in the web.config. Quoting from msdn: "timeout: Optional attribute. Specifies the time, in integer minutes, after which...
3
3538
by: rh.krish | last post by:
I have a typical ASP.NET 2.0 Forms authentication application which authenticates against Active Directory. I use non-persistent cookie so that the user is NOT remembered across browser sessions. The timeout is set to 10 minutes. Here is the important code snippets that I took from my original code: string roleToCheck = .....; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, member.UserName, DateTime.Now,...
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.