Hi,
I am using cookies to keep track if a user is logged into my system,
and would like to display the time that the user has left logged in.
One solution is to display the time left until the cookie expires.
Does anyone know how to retrieve the expiry time of a particular
cookie?
TIA
Jeff 6 25041
If the above is not possible, then I suppose one solution is to store
the expiry time in an additional cookie.
On Tue, 02 May 2006 03:05:15 -0700, mymatebob wrote: If the above is not possible, then I suppose one solution is to store the expiry time in an additional cookie.
Or re-set the cookie for a known expiry time on every page view (say ten
minutes and 20 seconds) then countdown in Javascript for ten minutes (the
extra 20 seconds is grace period and to allow for the page to
download/Javascript to start).
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer http://www.gphpedit.org | PHP editor for Gnome 2 http://www.andyjeffries.co.uk | Personal site and photos
Sounds a bit overly complicated! But an interesting solution.
It seems strange that there's no method in PHP for obtaining the cookie
expiry time. Ah well. In the mean time I have stuck with the "storing
expiry time in another cookie" method. Suppose I could add a Java
Script function to check the values every second to produce a real time
"time left until log out" counter.
Many thanks for the response!
Jeff
On Wed, 03 May 2006 02:32:36 -0700, my*******@googlemail.com wrote: Sounds a bit overly complicated! But an interesting solution.
Not that complex though, it's only a matter of iterating through $_COOKIE
and resetting each one with a known expiry time (strtotime("+10 minutes
and 20 seconds")). You could do this in a single file and automatically
use it on every page using php_value auto_prepend_file in the Apache
virtualhost.
It seems strange that there's no method in PHP for obtaining the cookie expiry time.
It's not really strange, if you examine the HTTP spec (or watch HTTP
headers using Firefox's Live HTTP Headers) you'll find the browser doesn't
send back the expiry date to the server, only the name and value.
Therefore it's not strange that PHP can't obtain the information, it's
never told (and it can't just remember what it set because it could have
been changed with Javascript or by editing the cookies.txt file).
Ah well. In the mean time I have stuck with the "storing expiry time in another cookie" method. Suppose I could add a Java Script function to check the values every second to produce a real time "time left until log out" counter.
Many thanks for the response!
You're welcome.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer http://www.gphpedit.org | PHP editor for Gnome 2 http://www.andyjeffries.co.uk | Personal site and photos
Ah! That IS a good solution. I was thinking of setting a default expiry
of 4 hours, but with your solution, the cookies keep in date as long as
the user is actively using the website - much more user friendly.
Thanks for explaining the missing functions I was looking for in PHP. I
saw the cookie expiry date in the "View Cookies" Firefox extension and
just assumed the value would be readily available somehow.
Cheers
Jeff
On Thu, 04 May 2006 00:12:32 -0700, my*******@googlemail.com wrote: Ah! That IS a good solution. I was thinking of setting a default expiry of 4 hours, but with your solution, the cookies keep in date as long as the user is actively using the website - much more user friendly.
Thanks for explaining the missing functions I was looking for in PHP. I saw the cookie expiry date in the "View Cookies" Firefox extension and just assumed the value would be readily available somehow.
You're more than welcome mate, best of luck with your project.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer http://www.gphpedit.org | PHP editor for Gnome 2 http://www.andyjeffries.co.uk | Personal site and photos This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vince C. |
last post by:
Hi all.
I'm trying to set a cookie expiry date but my script is JS (JavaScript). I've
tried
Response.Cookies("Test").Expires = Date();
Response.Cookies("Test").Expires =...
|
by: |
last post by:
How does one read and write the cookie expiration date. At the moment my
code is returning a value BUT a garbled value:
'//Write cookie...
Response.Cookies("Propsect").Expires = Date() + 1
...
|
by: David Graham |
last post by:
Hi
I have asked this question in alt.php as the time() function as used in
setcookie belongs to php - or does it belong equally in the javascript
camp - bit confused about that. Anyway, can anyone...
|
by: Hardeep Rakhra |
last post by:
Hi i have a snippet of JS that i want to change so that the cookie it
creates lasts only 48 hours. (or any other length of time i decide, but
48hours seems right for now)
Only thing i can't...
|
by: Ray |
last post by:
Below is the code to save the cookie and set the expiry date of the cooki
Response.Cookies.Value ="Hello"
DateTime dt = DateTime.Now
TimeSpan ts = new TimeSpan(0,0,10,0)
Response.Cookies...
|
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...
|
by: mymatebob |
last post by:
Hi,
I am using cookies to keep track if a user is logged into my system,
and would like to display the time that the user has left logged in.
One solution is to display the time left until the...
|
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...
|
by: sazan |
last post by:
Hi,
I am new in java, i needed help in setting the expiry time for the session. I need the session to expire after 3 minutes, then show a table of the pages i visited during the 3 minutes and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |