]> granicus.if.org Git - php/commitdiff
Add an API function for setting the session id from a session module...
authorSterling Hughes <sterling@php.net>
Tue, 11 Sep 2001 10:13:44 +0000 (10:13 +0000)
committerSterling Hughes <sterling@php.net>
Tue, 11 Sep 2001 10:13:44 +0000 (10:13 +0000)
# The SRM folks wanted/needed this

ext/session/php_session.h
ext/session/session.c

index a21132da93900d2a047b15a98566c3776ec9d953..0ad182e85868b3114cd9af2517ef15965b4b465f 100644 (file)
@@ -156,6 +156,8 @@ int php_session_register_serializer(const char *name,
                int (*encode)(PS_SERIALIZER_ENCODE_ARGS),
                int (*decode)(PS_SERIALIZER_DECODE_ARGS));
 
+PHPAPI void php_session_set_id(char *id TSRMLS_DC);
+
 #define PS_ADD_VARL(name,namelen) \
        zend_hash_add_empty_element(&PS(vars), name, namelen + 1)
 
index 3e9f9931f364b5f6e097b1b0aea8778891ea3ae6..5edb0d4fd1591869a15f693e765509bd51f22596 100644 (file)
@@ -211,6 +211,15 @@ int php_session_register_module(ps_module *ptr)
        return ret;
 }
 
+PHPAPI void php_session_set_id(char *id TSRMLS_DC)
+{
+       if (PS(id))
+               efree(PS(id));
+
+       PS(id) = estrdup(id);
+}
+
+
 PHP_MINIT_FUNCTION(session);
 PHP_RINIT_FUNCTION(session);
 PHP_MSHUTDOWN_FUNCTION(session);
@@ -955,7 +964,6 @@ static zend_bool php_session_destroy(TSRMLS_D)
        return retval;
 }
 
-
 /* {{{ proto void session_set_cookie_params(int lifetime [, string path [, string domain [, bool secure]]])
    Set session cookie parameters */
 PHP_FUNCTION(session_set_cookie_params)
@@ -1132,8 +1140,7 @@ PHP_FUNCTION(session_id)
 
        if (ac == 1) {
                convert_to_string_ex(p_name);
-               if (PS(id)) efree(PS(id));
-               PS(id) = estrndup(Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name));
+               php_session_set_id(Z_STRVAL_PP(p_name) TSRMLS_CC);
        }
        
        RETVAL_STRING(old, 0);