Re: Setting cache_expire at runtime [solved]

From: Date: Sat, 20 Oct 2001 02:22:33 +0000
Subject: Re: Setting cache_expire at runtime [solved]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-71650@lists.php.net to get a copy of this message
On Fri, Oct 19, 2001 at 04:03:27PM +0600, Anuradha Ratnaweera wrote: > > Is it possible to set session.cache_expire with a php function in a similar > manner to session_cache_limiter()? > > I can do a workaround using header() etc. but am just curious if there is a > neater way. Solved the problem by createing a new function session_cache_limiter() which gets/sets session.cache_limiter. Here is the patch which applies to php-4.0.6. Cheers, Anuradha -- Debian GNU/Linux (kernel 2.4.12) Today is the tomorrow you worried about yesterday. diff -rua php-4.0.6-orig/ext/session/php_session.h php-4.0.6/ext/session/php_session.h --- php-4.0.6-orig/ext/session/php_session.h Thu May 3 21:48:49 2001 +++ php-4.0.6/ext/session/php_session.h Fri Oct 19 17:17:12 2001 @@ -114,6 +114,7 @@ PHP_FUNCTION(session_unset); PHP_FUNCTION(session_set_save_handler); PHP_FUNCTION(session_cache_limiter); +PHP_FUNCTION(session_cache_expire); PHP_FUNCTION(session_set_cookie_params); PHP_FUNCTION(session_get_cookie_params); PHP_FUNCTION(session_write_close); diff -rua php-4.0.6-orig/ext/session/session.c php-4.0.6/ext/session/session.c --- php-4.0.6-orig/ext/session/session.c Thu May 24 18:42:06 2001 +++ php-4.0.6/ext/session/session.c Fri Oct 19 21:21:21 2001 @@ -64,6 +64,7 @@ PHP_FE(session_unset, NULL) PHP_FE(session_set_save_handler, NULL) PHP_FE(session_cache_limiter, NULL) + PHP_FE(session_cache_expire, NULL) PHP_FE(session_set_cookie_params, NULL) PHP_FE(session_get_cookie_params, NULL) PHP_FE(session_write_close, NULL) @@ -1134,6 +1135,28 @@ } /* }}} */ +/* {{{ proto int session_cache_expire([int new_cache_expire]) + Return the current cache expire. If new_cache_expire is given, the current cache_expire is replaced with new_cache_expire */ +PHP_FUNCTION(session_cache_expire) +{ + zval **p_cache_expire; + int ac = ZEND_NUM_ARGS(); + long old; + PSLS_FETCH(); + + old = PS(cache_expire); + + if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_cache_expire) == FAILURE) + WRONG_PARAM_COUNT; + + if (ac == 1) { + convert_to_long_ex(p_cache_expire); + PS(cache_expire) = Z_LVAL_PP(p_cache_expire); + } + + RETVAL_LONG(old); +} +/* }}} */ /* {{{ static void php_register_var(zval** entry PSLS_DC PLS_DC) */ static void php_register_var(zval** entry PSLS_DC PLS_DC)

« previous php.general (#71650) next »