]> granicus.if.org Git - php/commitdiff
Extend HTTP headers for private-caching and add a new PHP function
authorSascha Schumann <sas@php.net>
Fri, 1 Sep 2000 15:56:26 +0000 (15:56 +0000)
committerSascha Schumann <sas@php.net>
Fri, 1 Sep 2000 15:56:26 +0000 (15:56 +0000)
session_cache_limiter.

Submitted by: Jon Parise <jon@csh.rit.edu>

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

index 9a143d0401aa4692da65d3bc37bf59d28a1cc238..b20967ead608c4270e2bfff7e11df1479985f00b 100644 (file)
@@ -112,6 +112,7 @@ PHP_FUNCTION(session_start);
 PHP_FUNCTION(session_destroy);
 PHP_FUNCTION(session_unset);
 PHP_FUNCTION(session_set_save_handler);
+PHP_FUNCTION(session_cache_limiter);
 PHP_FUNCTION(session_set_cookie_params);
 PHP_FUNCTION(session_get_cookie_params);
 
index 18aafd75882d228d47f6336fd0ae8d8b6027300f..117247adb57dd7c551031922966ad92fb1a6a4c4 100644 (file)
@@ -62,7 +62,8 @@ 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)
+       PHP_FE(session_cache_limiter, NULL)
+       PHP_FE(session_set_cookie_params, NULL)
        PHP_FE(session_get_cookie_params, NULL)
        {0}
 };
@@ -677,7 +678,7 @@ CACHE_LIMITER_FUNC(nocache)
 {
        ADD_COOKIE("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
        /* For HTTP/1.1 conforming clients and the rest (MSIE 5) */
-       ADD_COOKIE("Cache-Control: no-cache, post-check=0, pre-check=0");
+       ADD_COOKIE("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
        /* For HTTP/1.0 conforming clients */
        ADD_COOKIE("Pragma: no-cache");
 }
@@ -689,7 +690,7 @@ static php_session_cache_limiter php_session_cache_limiters[] = {
        {0}
 };
 
-static void _php_session_cache_limiter(PSLS_D)
+static int _php_session_cache_limiter(PSLS_D)
 {
        php_session_cache_limiter *lim;
        SLS_FETCH();
@@ -704,15 +705,17 @@ static void _php_session_cache_limiter(PSLS_D)
                } else {
                        php_error(E_WARNING, "Cannot send session cache limiter - headers already sent");
                }       
-               return;
+               return (-2);
        }
        
        for (lim = php_session_cache_limiters; lim->name; lim++) {
                if (!strcasecmp(lim->name, PS(cache_limiter))) {
                        lim->func(PSLS_C);
-                       break;
+                       return (0);
                }
        }
+
+       return (-1);
 }
 
 #define COOKIE_FMT             "Set-Cookie: %s=%s"
@@ -1179,6 +1182,30 @@ PHP_FUNCTION(session_id)
 }
 /* }}} */
 
+/* {{{ proto string session_cache_limiter([string new_cache_limiter])
+   Return the current cache limiter. If new_cache_limited is given, the current cache_limiter is replaced with new_cache_limiter */
+PHP_FUNCTION(session_cache_limiter)
+{
+       pval **p_cache_limiter;
+       int ac = ZEND_NUM_ARGS();
+       char *old;
+       PSLS_FETCH();
+
+       old = estrdup(PS(cache_limiter));
+
+       if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_cache_limiter) == FAILURE)
+               WRONG_PARAM_COUNT;
+
+       if (ac == 1) {
+               convert_to_string_ex(p_cache_limiter);
+               efree(PS(cache_limiter));
+               PS(cache_limiter) = estrndup((*p_cache_limiter)->value.str.val, (*p_cache_limiter)->value.str.len);
+       }
+       
+       RETVAL_STRING(old, 0);
+}
+/* }}} */
+
 
 /* {{{ static void php_register_var(zval** entry PSLS_DC PLS_DC) */
 static void php_register_var(zval** entry PSLS_DC PLS_DC)