From c24900dfa449135c2304550f01fc4592e3924270 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 29 May 2005 16:51:25 +0000 Subject: [PATCH] Added an optional remove old session parameter to session_regenerate_id(). --- NEWS | 1 + ext/session/session.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index f3d3c3ef3d..fe5b7e3632 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2004, PHP 5.1.0 - Upgraded PCRE library to version 5.0. (Andrei) +- Added an optional remove old session parameter to session_regenerate_id(). (Ilia) - Added array type hinting. (Dmitry) - Removed php_check_syntax() function which never worked properly. (Ilia) - Removed garbage manager in Zend Engine which results in more aggressive diff --git a/ext/session/session.c b/ext/session/session.c index 7e96da4d6a..e2efb9ee74 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1462,12 +1462,24 @@ PHP_FUNCTION(session_id) } /* }}} */ -/* {{{ proto bool session_regenerate_id() - Update the current session id with a newly generated one. */ +/* {{{ proto bool session_regenerate_id([bool delete_old_session]) + Update the current session id with a newly generated one. If delete_old_session is set to true, remove the old session. */ PHP_FUNCTION(session_regenerate_id) { + zend_bool del_ses = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &del_ses) == FAILURE) { + WRONG_PARAM_COUNT; + } + if (PS(session_status) == php_session_active) { - if (PS(id)) efree(PS(id)); + if (PS(id)) { + if (del_ses && PS(mod)->s_destroy(&PS(mod_data), PS(id) TSRMLS_CC) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session object destruction failed"); + RETURN_FALSE; + } + efree(PS(id)); + } PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC); -- 2.50.1