cvs: /php4/ext/session php_session.h session.c

From: Date: Sun, 31 Oct 1999 13:27:11 +0000
Subject: cvs: /php4/ext/session php_session.h session.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-5809@lists.php.net to get a copy of this message
sas Sun Oct 31 08:27:11 1999 EDT Modified files: /php4/ext/session php_session.h session.c Log: Change session.lifetime to session.cookie_lifetime. And: Index: php4/ext/session/php_session.h diff -u php4/ext/session/php_session.h:1.20 php4/ext/session/php_session.h:1.21 --- php4/ext/session/php_session.h:1.20 Fri Oct 22 04:10:08 1999 +++ php4/ext/session/php_session.h Sun Oct 31 08:26:40 1999 @@ -77,7 +77,9 @@ char *extern_referer_chk; char *entropy_file; int entropy_length; - int lifetime; + int cookie_lifetime; + char *cookie_path; + char *cookie_domain; zend_bool define_sid; zend_bool use_cookies; ps_module *mod; Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.59 php4/ext/session/session.c:1.60 --- php4/ext/session/session.c:1.59 Sun Oct 24 12:17:45 1999 +++ php4/ext/session/session.c Sun Oct 31 08:26:40 1999 @@ -68,8 +68,9 @@ PHP_INI_ENTRY("session.auto_start", "0", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.gc_probability", "1", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.gc_maxlifetime", "1440", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("session.lifetime", "0", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.serialize_handler", "php", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("session.cookie_lifetime", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("session.cookie_path", "", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.use_cookies", "1", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.extern_referer_check", "", PHP_INI_ALL, NULL) PHP_INI_ENTRY("session.entropy_file", "", PHP_INI_ALL, NULL) @@ -377,27 +378,52 @@ #define COOKIE_FMT "Set-cookie: %s=%s" #define COOKIE_EXPIRES "; expires=" +#define COOKIE_PATH "; path=" +#define COOKIE_DOMAIN "; domain=" static void _php_session_send_cookie(PSLS_D) { - int len; + int len; + int pathlen; + int domainlen; char *cookie; char *date_fmt = NULL; len = strlen(PS(session_name)) + strlen(PS(id)) + sizeof(COOKIE_FMT); - if (PS(lifetime) > 0) { - date_fmt = php3_std_date(time(NULL) + PS(lifetime)); + if (PS(cookie_lifetime) > 0) { + date_fmt = php3_std_date(time(NULL) + PS(cookie_lifetime)); len += sizeof(COOKIE_EXPIRES) + strlen(date_fmt); } + + pathlen = strlen(PS(cookie_path)); + if (pathlen > 0) { + len += pathlen + sizeof(COOKIE_PATH); + } + + domainlen = strlen(PS(cookie_domain)); + if (domainlen > 0) { + len += domainlen + sizeof(COOKIE_DOMAIN); + } + cookie = ecalloc(len + 1, 1); len = snprintf(cookie, len, COOKIE_FMT, PS(session_name), PS(id)); - if (PS(lifetime) > 0) { + if (PS(cookie_lifetime) > 0) { strcat(cookie, COOKIE_EXPIRES); strcat(cookie, date_fmt); len += strlen(COOKIE_EXPIRES) + strlen(date_fmt); efree(date_fmt); } + + if (pathlen > 0) { + strcat(cookie, COOKIE_PATH); + strcat(cookie, PS(cookie_path)); + } + + if (domainlen > 0) { + strcat(cookie, COOKIE_DOMAIN); + strcat(cookie, PS(cookie_domain)); + } sapi_add_header(cookie, len); } @@ -873,7 +899,9 @@ PS(gc_maxlifetime) = INI_INT("session.gc_maxlifetime"); PS(extern_referer_chk) = estrdup(INI_STR("session.extern_referer_check")); PS(id) = NULL; - PS(lifetime) = INI_INT("session.lifetime"); + PS(cookie_lifetime) = INI_INT("session.cookie_lifetime"); + PS(cookie_path) = estrdup(INI_STR("session.cookie_path")); + PS(cookie_domain) = estrdup(INI_STR("session.cookie_domain")); PS(nr_open_sessions) = 0; PS(mod_data) = NULL; } @@ -887,6 +915,8 @@ if(PS(save_path)) efree(PS(save_path)); if(PS(session_name)) efree(PS(session_name)); if(PS(id)) efree(PS(id)); + efree(PS(cookie_path)); + efree(PS(cookie_domain)); zend_hash_destroy(&PS(vars)); }

« previous php.version4 (#5809) next »