By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

Modify Session Cookie on Every Page Load

P: n/a
I've got a PHP system working on a development server (Windows
2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on
the testing server (same except PHP 4.2.3). I upgraded the PHP on the
testing server but that didn't seem to make any difference. One
difference I noticed is that on the dev server, the session cookie is
modified on EVERY page load. On the testing server the cookie gets
created alright but it doesn't seem to be touched after that (and yes,
I checked to be sure the PHP code is the same on the two machines).
Is this controlled by a setting in php.ini? If so, I cannot figure
out which one. Is it controlled by IIS in some way? Again, I cannot
find anything that tells me where. Since the development server is
working, I'd like that behavior (modifying the cookie on every page
load) to be implemented on the test server but cannot figure out how.
Any suggestions would be most appreciated.

--
Henry
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Henry Hartley wrote:
I've got a PHP system working on a development server (Windows
2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on
the testing server (same except PHP 4.2.3). I upgraded the PHP on the
testing server but that didn't seem to make any difference. One
difference I noticed is that on the dev server, the session cookie is
modified on EVERY page load.
???? And that is good? ?!?!?!?!

one session <===> one cookie
one cookie <===> one session

If you get different cookies that means php is dealing with different
sessions.
On the testing server the cookie gets
created alright but it doesn't seem to be touched after that (and yes,
I checked to be sure the PHP code is the same on the two machines).
Isn't this what you want? ?!?!?!?!
Is this controlled by a setting in php.ini? If so, I cannot figure
out which one.
Check that the directory specified in "session.save_path" really exists.
Is it controlled by IIS in some way? Again, I cannot
find anything that tells me where.
Check the permission for the directory.
Since the development server is
working,
is it? ?!?!?!?!
I'd like that behavior (modifying the cookie on every page
load) to be implemented on the test server but cannot figure out how.


Why?
Why do you want a cookie that changes on *every* page load?
Perhaps you are trying something for which cookies may not be the best
option?

--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Jul 17 '05 #2

P: n/a
Accessing the cookie with every page load is usually to reset the expiry
time. In this way the cookie will expire some time after the last page
access, not sometime after it was first created.

--
Tony Marston

http://www.tonymarston.net

"Pedro Graca" <he****@hotpop.com> wrote in message
news:sl*******************@ID-203069.user.uni-berlin.de...
Henry Hartley wrote:
I've got a PHP system working on a development server (Windows
2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on
the testing server (same except PHP 4.2.3). I upgraded the PHP on the
testing server but that didn't seem to make any difference. One
difference I noticed is that on the dev server, the session cookie is
modified on EVERY page load.


???? And that is good? ?!?!?!?!

one session <===> one cookie
one cookie <===> one session

If you get different cookies that means php is dealing with different
sessions.
On the testing server the cookie gets
created alright but it doesn't seem to be touched after that (and yes,
I checked to be sure the PHP code is the same on the two machines).


Isn't this what you want? ?!?!?!?!
Is this controlled by a setting in php.ini? If so, I cannot figure
out which one.


Check that the directory specified in "session.save_path" really exists.
Is it controlled by IIS in some way? Again, I cannot
find anything that tells me where.


Check the permission for the directory.
Since the development server is
working,


is it? ?!?!?!?!
I'd like that behavior (modifying the cookie on every page
load) to be implemented on the test server but cannot figure out how.


Why?
Why do you want a cookie that changes on *every* page load?
Perhaps you are trying something for which cookies may not be the best
option?

--
USENET would be a better place if everybody read: | to mail me:
simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this
post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain
text |
http://www.expita.com/nomime.html | and *NO*
attachments. |

Jul 17 '05 #3

P: n/a
Tony Marston wrote:
Accessing the cookie with every page load is usually to reset the expiry
time. In this way the cookie will expire some time after the last page
access, not sometime after it was first created.


Hmmm, of course you're right. I just didn't think of using 'sticky'
cookies for the session id.

I think it's best to let the user decide when the session is over rather
than forcing a cookie timeout of 20 minutes (or an hour, or whatever).
When the user want to terminate the session he can close the browser or
log out (and logging out will delete the cookie).
--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Jul 17 '05 #4

P: n/a
>> Accessing the cookie with every page load is usually to reset the expiry
time. In this way the cookie will expire some time after the last page
access, not sometime after it was first created.


Hmmm, of course you're right. I just didn't think of using 'sticky'
cookies for the session id.

I think it's best to let the user decide when the session is over rather
than forcing a cookie timeout of 20 minutes (or an hour, or whatever).
When the user want to terminate the session he can close the browser or
log out (and logging out will delete the cookie).


You DO want to time out sessions eventually, as all those files
cluttering up the server will eventually slow it down, to say nothing
of chewing up a lot of disk space. Do you think a real user is
going to come back expecting to still be logged in if he hasn't
accessed a page in 24 hours? A month? A year? Timeouts don't
have to be annoyingly short. I'm not sure an hour qualifies as
"annoyingly short" if it's counted from the last page refresh,
though, especially if it's a security-sensitive page like a bill-pay
page for a bank.

Also, the *server* doesn't know when the user has closed the browser.
It needs to eventually clean up old sessions.

Gordon L. Burditt
Jul 17 '05 #5

P: n/a
Pedro Graca <he****@hotpop.com> wrote in message news:<sl*******************@ID-203069.user.uni-berlin.de>...
<snip>
I think it's best to let the user decide when the session is over rather
than forcing a cookie timeout of 20 minutes (or an hour, or whatever).
When the user want to terminate the session he can close the browser or
log out (and logging out will delete the cookie).


The "real" session timeout is handled by garbage collector
(session.gc_maxlifetime and the time you last access the session file)
than with cookies. The cookie life time, just helps you to "continue"
your sessions incase if you closed/restarted your browser.

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6

P: n/a
Pedro Graca <he****@hotpop.com> wrote in message news:<sl*******************@ID-203069.user.uni-berlin.de>...
Tony Marston wrote:
Accessing the cookie with every page load is usually to reset the expiry
time. In this way the cookie will expire some time after the last page
access, not sometime after it was first created.


Hmmm, of course you're right. I just didn't think of using 'sticky'
cookies for the session id.


The odd thing is that one server is resetting the cookie on every page
load (not creating a new cookie, just updating the existing one) and
the other server justs sets the cookie once and seems to forget about
it. Of course, it's still *reading* the cookie or it wouldn't know
what the session ID was but I'm trying to understand why the two
servers are behaving differently. I don't know if this is a PHP
setting (in php.ini) or an IIS setting (and if so, where I can find
and change it) or possibly some other setting that I haven't thought
of.

--
Henry
Jul 17 '05 #7

P: n/a
he**********@westat.com (Henry Hartley) wrote in message news:<2d**************************@posting.google. com>...
<snip>
I don't know if this is a PHP
setting (in php.ini)


Then, why can't do a diff between two ini files?

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.