diff options
author | Mark L. Woodward <mlwmohawk@php.net> | 2002-03-29 16:00:27 +0000 |
---|---|---|
committer | Mark L. Woodward <mlwmohawk@php.net> | 2002-03-29 16:00:27 +0000 |
commit | 346d74a1464ecfb6bc7b8f7a273774ecf913f45c (patch) | |
tree | 022c9a4adf9a8cf51a4d397657887693a17e18c2 /ext/session/session.c | |
parent | eab1211ed1e8ac07b8995f6d62de0f285fa7f254 (diff) | |
download | php-git-346d74a1464ecfb6bc7b8f7a273774ecf913f45c.tar.gz |
Added field to ps_module structure to hold function pointer for the creation
of the session ID string. Default PS_MOD() macro sets this to be the default
creation routine. PS_MOD_SID() macro sets this to a handlers session ID
creation routine.
Diffstat (limited to 'ext/session/session.c')
-rw-r--r-- | ext/session/session.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/session/session.c b/ext/session/session.c index 9e0993dbf6..21480fc2b9 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -495,7 +495,7 @@ static void php_session_decode(const char *val, int vallen TSRMLS_DC) static char hexconvtab[] = "0123456789abcdef"; -static char *_php_create_id(int *newlen TSRMLS_DC) +char *php_session_create_id(PS_CREATESID_ARGS) { PHP_MD5_CTX context; unsigned char digest[16]; @@ -548,11 +548,23 @@ static void php_session_initialize(TSRMLS_D) { char *val; int vallen; - + + /* Open session handler first */ if (PS(mod)->open(&PS(mod_data), PS(save_path), PS(session_name) TSRMLS_CC) == FAILURE) { php_error(E_ERROR, "Failed to initialize session module"); return; } + + /* If there is no ID, use session module to create one */ + if (!PS(id)) + PS(id) = PS(mod)->createsid(&PS(mod_data), NULL); + + /* Read data */ + /* Question: if you create a SID here, should you also try to read data? + * I'm not sure, but while not doing so will remove one session operation + * it could prove usefull for those sites which wish to have "default" + * session information + */ php_session_track_init(TSRMLS_C); if (PS(mod)->read(&PS(mod_data), PS(id), &val, &vallen TSRMLS_CC) == SUCCESS) { php_session_decode(val, vallen TSRMLS_CC); @@ -560,7 +572,6 @@ static void php_session_initialize(TSRMLS_D) } } - static void php_session_save_current_state(TSRMLS_D) { char *val; @@ -918,8 +929,7 @@ PHPAPI void php_session_start(TSRMLS_D) PS(apply_trans_sid) = 1; } - if (!PS(id)) - PS(id) = _php_create_id(NULL TSRMLS_CC); + php_session_initialize(TSRMLS_C); if (!PS(use_cookies) && send_cookie) { if (PS(use_trans_sid)) @@ -950,7 +960,6 @@ PHPAPI void php_session_start(TSRMLS_D) } php_session_cache_limiter(TSRMLS_C); - php_session_initialize(TSRMLS_C); if (PS(mod_data) && PS(gc_probability) > 0) { int nrdels = -1; |