]> granicus.if.org Git - php/commitdiff
Added an optional remove old session parameter to session_regenerate_id().
authorIlia Alshanetsky <iliaa@php.net>
Sun, 29 May 2005 16:51:25 +0000 (16:51 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 29 May 2005 16:51:25 +0000 (16:51 +0000)
NEWS
ext/session/session.c

diff --git a/NEWS b/NEWS
index f3d3c3ef3d222f2a85f37535b254e41048cc00c4..fe5b7e3632d94759d38ffb7931d10e7ad7ec2570 100644 (file)
--- 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
index 7e96da4d6a43aac2bac31c59f47793cee6883acf..e2efb9ee745939fa0a378718a9e393796f32c4cf 100644 (file)
@@ -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);