]> granicus.if.org Git - php/commitdiff
Implemented setting of session cookie parameters.
authorAndrei Zmievski <andrei@php.net>
Fri, 4 Feb 2000 23:34:24 +0000 (23:34 +0000)
committerAndrei Zmievski <andrei@php.net>
Fri, 4 Feb 2000 23:34:24 +0000 (23:34 +0000)
@ Added session_set_cookie_params() function. (Andrei)

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

index 97df5fc7bc2b00f88ae51e33e7970bb182be57ae..8cbd86a613fa3b5720c3aeff23d3476ca5efd015 100644 (file)
@@ -111,6 +111,7 @@ PHP_FUNCTION(session_start);
 PHP_FUNCTION(session_destroy);
 PHP_FUNCTION(session_unset);
 PHP_FUNCTION(session_set_save_handler);
+PHP_FUNCTION(session_set_cookie_params);
 
 #ifdef ZTS
 #define PSLS_D php_ps_globals *ps_globals
index ed359e973792af777e66c69f3fe9c70e7a43157b..5b3ba3bb837b83828384d3dfafb9310cb3af0178 100644 (file)
@@ -60,6 +60,7 @@ function_entry session_functions[] = {
        PHP_FE(session_destroy, NULL)
        PHP_FE(session_unset, NULL)
        PHP_FE(session_set_save_handler, NULL)
+    PHP_FE(session_set_cookie_params, NULL)
        {0}
 };
 
@@ -798,6 +799,42 @@ static void _php_session_destroy(PSLS_D)
        php_rinit_session_globals(PSLS_C);
 }
 
+
+/* {{{ proto void session_set_cookie_params(int lifetime [, string path [, string domain ]])
+   Set session cookie parameters */
+PHP_FUNCTION(session_set_cookie_params)
+{
+    zval **lifetime, **path, **domain;
+       PSLS_FETCH();
+
+       if (!PS(use_cookies))
+               return;
+
+    if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 3 ||
+               zend_get_parameters_ex(ZEND_NUM_ARGS(), &lifetime, &path, &domain) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       convert_to_long_ex(lifetime);
+       PS(cookie_lifetime) = (*lifetime)->value.lval;
+
+       if (ZEND_NUM_ARGS() > 1) {
+               convert_to_string_ex(path);
+               efree(PS(cookie_path));
+               PS(cookie_path) = estrndup((*path)->value.str.val,
+                                                                  (*path)->value.str.len);
+
+               if (ZEND_NUM_ARGS() > 2) {
+                       convert_to_string_ex(domain);
+                       efree(PS(cookie_domain));
+                       PS(cookie_domain) = estrndup((*domain)->value.str.val,
+                                                                                (*domain)->value.str.len);
+               }
+       }
+}
+/* }}} */
+
+
 /* {{{ proto string session_name([string newname])
    return the current session name. if newname is given, the session name is replaced with newname */
 PHP_FUNCTION(session_name)