diff options
| author | Sascha Schumann <sas@php.net> | 1999-12-22 00:11:04 +0000 |
|---|---|---|
| committer | Sascha Schumann <sas@php.net> | 1999-12-22 00:11:04 +0000 |
| commit | f8891483357ae5494a047a4e12af70bbbe55bf11 (patch) | |
| tree | 94a080a5e893ab6a55e3506c1634d7903fcf061a /ext/session/session.c | |
| parent | a2276107ab211783669daa1ff47be50f96eef2dc (diff) | |
| download | php-git-f8891483357ae5494a047a4e12af70bbbe55bf11.tar.gz | |
Warn users, if they have disabled gpc_globals and track_vars. Also work
correctly, if users have enabled track_vars/disabled gpc_globals.
Diffstat (limited to 'ext/session/session.c')
| -rw-r--r-- | ext/session/session.c | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/ext/session/session.c b/ext/session/session.c index 9a56e5e698..c1aa7740ef 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -623,6 +623,9 @@ static void _php_session_start(PSLS_D) char *p; int send_cookie = 1; int define_sid = 1; + int found_sid = 0; + zend_bool gpc_globals; + zend_bool track_vars; int module_number = PS(module_number); int nrand; int lensess; @@ -632,28 +635,56 @@ static void _php_session_start(PSLS_D) lensess = strlen(PS(session_name)); + gpc_globals = INI_BOOL("gpc_globals"); + track_vars = INI_BOOL("track_vars"); + + if (!gpc_globals && !track_vars) { + php_error(E_ERROR, "The sessions module will not work, if you have disabled track_vars and gpc_globals. Enable at least one of them."); + return; + } + /* check whether a symbol with the name of the session exists - in the global symbol table */ + in the global symbol table. This requires gpc_globals to be enabled */ - if(!PS(id) && + if (gpc_globals && + !PS(id) && zend_hash_find(&EG(symbol_table), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS) { convert_to_string((*ppid)); PS(id) = estrndup((*ppid)->value.str.val, (*ppid)->value.str.len); send_cookie = 0; + found_sid = 1; } - /* if the previous section was successful, we check whether - a symbol with the name of the session exists in the global - HTTP_COOKIE_VARS array */ + /* if we did not find the session id yet, we check track_vars */ - if(!send_cookie && - zend_hash_find(&EG(symbol_table), "HTTP_COOKIE_VARS", - sizeof("HTTP_COOKIE_VARS"), (void **) &data) == SUCCESS && - (*data)->type == IS_ARRAY && - zend_hash_find((*data)->value.ht, PS(session_name), - lensess + 1, (void **) &ppid) == SUCCESS) { - define_sid = 0; + if (!found_sid && track_vars) { + if (zend_hash_find(&EG(symbol_table), "HTTP_COOKIE_VARS", + sizeof("HTTP_COOKIE_VARS"), (void **) &data) == SUCCESS && + (*data)->type == IS_ARRAY && + zend_hash_find((*data)->value.ht, PS(session_name), + lensess + 1, (void **) &ppid) == SUCCESS) { + define_sid = 0; + found_sid = 1; + } + + if (!found_sid && + zend_hash_find(&EG(symbol_table), "HTTP_GET_VARS", + sizeof("HTTP_GET_VARS"), (void **) &data) == SUCCESS && + (*data)->type == IS_ARRAY && + zend_hash_find((*data)->value.ht, PS(session_name), + lensess + 1, (void **) &ppid) == SUCCESS) { + found_sid = 1; + } + + if (!found_sid && + zend_hash_find(&EG(symbol_table), "HTTP_POST_VARS", + sizeof("HTTP_POST_VARS"), (void **) &data) == SUCCESS && + (*data)->type == IS_ARRAY && + zend_hash_find((*data)->value.ht, PS(session_name), + lensess + 1, (void **) &ppid) == SUCCESS) { + found_sid = 1; + } } /* check the REQUEST_URI symbol for a string of the form |
