summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-02-04 23:34:24 +0000
committerAndrei Zmievski <andrei@php.net>2000-02-04 23:34:24 +0000
commitc77aa759ea0cb1ba5e33beac8e106dd5801b1172 (patch)
tree747fc044ba51d7ef64d3a5baee0d3ec3a89f8903
parent8055da983011d27441fd560f39eea9bc0646580b (diff)
downloadphp-git-c77aa759ea0cb1ba5e33beac8e106dd5801b1172.tar.gz
Implemented setting of session cookie parameters.
@ Added session_set_cookie_params() function. (Andrei)
-rw-r--r--ext/session/php_session.h1
-rw-r--r--ext/session/session.c37
2 files changed, 38 insertions, 0 deletions
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)