What about something like this: (un-tested, just off the top
of my head) It'll set a cookie the first time a user gets
to the page, and will then only re-load data every 75+ seconds
(from the time the user first loads data) -- and only updates
the cookie when data is re-loaded
if (date(U) ($cookie_load+75)) {
print fetch from DB;
SetCookie(cookie_load, date(U));
}
else {
print Loaded ($cookie_load), now . date(U) . -- NOT
fetching\n;
}
if (!$cookie_load)
SetCookie(cookie_load, date(U));
---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515
-Original Message-
From: Chris Knipe [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 20, 2002 3:15 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Expiring certain session data while keeping the session
itself
Hiya, me again :-)
Is it possible to expire certain session data, while still keeping the
session itself in tact?
Example...
$_SESSION['AlwaysTrue'] = True;
$_SESSION['ExpireThis'] = 10:20:00;
At 10:19:50 the session is registered. AlwaysTrue must
remain True for as
long as the session itself is true (as specified in the
documentation - this
would be until the browser is closed, or after a certain
amount of inactive
time).
However, at 10:20:00 (10 seconds later), I want the
ExpireThis value of the
session, to be destroyed, without having to de-register the
entire session
(this would then also destroy the AlwaysTrue value...
Am I right in presuming this cannot be done, and I'll have to
come up with
my own little function to do this with? If so, how can I see
at what time a
session variable was written, or would I need to register the
time that the
session variable was set to the session as well? For instance
$_SESSION['AlwaysTrue'] = True;
$_SESSION['ExpireThis'] = 10:20:00;
$_SESSION['ExpireThisTime'] = 10:19:50;
Then, just do a comparison, and if ExpireThisTime is past
10:20:00, then
just delete that one variable...
There's no easier / better way to do this ??
Basically, I'm needing something like this to bring down the number of
possible database queries. I have a application which will have new
information in a database, every 75 seconds. The queries are
performed on
every single page that a user is logged in to on a site. To
make sure that
the same queries is not issued over and over on the database,
I want to
implement some sort of caching where I will only need to do
another query
after the database received new information (every 75
seconds). It's all
numbers (integers), so I was thinking It may well work if
I can save
these values to session data, and then just refresh the
session data every
75 seconds The problem is, there's lots of other
information saved to
the session as well, which I cannot afford to loose with a possible
session_destroy()..
--
me
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php