# Resending session cookies patch

- Thread: https://externals.io/message/37642
- Original archive: https://news-web.php.net/php.internals/37642
- Started by Brian Moon on 2008-05-14T02:40:51+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #37642 — Brian Moon — 2008-05-14T02:40:51+00:00

URL: https://externals.io/message/37642#37642

Here is a patch that will add an ini setting (session.cookie_resend) to 
resend session cookies whenever a session is started.  The point of this 
is to keep a cookie's expiration fresh as users use a site.  Currently, 
once a session is started, it will expire after cookie_lifetime no 
matter what.  For my applications, I need that cookie to only expire 
after cookie_lifetime of non use.  I also added a function called 
session_send_cookie() that will send the cookie right then in case you 
don't have access to the ini settings or want to make that customized 
based on events in your application.

The only caveat of this is that currently session_send_cookie() will 
send the Set-Cookie header every time it is called.  There is no flag in 
the _php_ps_globals struct to indicate that a cookie has been sent other 
than PS(send_cookie).  However, I can't rely on that because if the 
session is found and session.cookie_resend is 0 PS(send_cookie) is set 
to 0 already.  I could add a new flag (cookie_sent?) and track that 
anywhere that php_session_send_cookie is called or even inside 
php_session_send_cookie.  But, the coding style of this file did not 
seem to favor altering PS() inside that function.  It does not currently 
check PS(send_cookie).  It simply just fires off the Set-Cookie header.

Thoughts?

-- 

Brian Moon
Senior Developer/Engineer
------------------------------
When you care enough to spend the very least.
http://dealnews.com/
