From: Andrei Zmievski Date: Fri, 4 Feb 2000 23:34:24 +0000 (+0000) Subject: Implemented setting of session cookie parameters. X-Git-Tag: BEFORE_SAPIFICATION_FEB_10_2000~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c77aa759ea0cb1ba5e33beac8e106dd5801b1172;p=php Implemented setting of session cookie parameters. @ Added session_set_cookie_params() function. (Andrei) --- diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 97df5fc7bc..8cbd86a613 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -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 diff --git a/ext/session/session.c b/ext/session/session.c index ed359e9737..5b3ba3bb83 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -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)