diff options
author | Arpad Ray <arraypad@gmail.com> | 2013-06-27 11:27:49 +0100 |
---|---|---|
committer | Arpad Ray <arraypad@gmail.com> | 2013-06-27 12:29:44 +0100 |
commit | b66c14b0c82ad0ed4ea117f7b789eef6e3a95ef4 (patch) | |
tree | 3717bcbf6d8632c480bd1f059ee235db1b55090d /ext/session/mod_user.c | |
parent | 60bbc78bde18d2d21cd4c0eaf86d348368c8aca9 (diff) | |
parent | 6809c388b5d8bb03515f7b4ba391724f9a8df8e0 (diff) | |
download | php-git-b66c14b0c82ad0ed4ea117f7b789eef6e3a95ef4.tar.gz |
Merge PR 109 - Add create_sid to session_set_save_handler and SessionHandler
Allows user session handlers to create session IDs by adding an optional
7th argument to session_set_save_handler() and a create_sid() method
to SessionHandler.
Diffstat (limited to 'ext/session/mod_user.c')
-rw-r--r-- | ext/session/mod_user.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 57d7bd0edc..e4261df294 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -23,7 +23,7 @@ #include "mod_user.h" ps_module ps_mod_user = { - PS_MOD(user) + PS_MOD_SID(user) }; #define SESS_ZVAL_LONG(val, a) \ @@ -183,6 +183,39 @@ PS_GC_FUNC(user) FINISH; } +PS_CREATE_SID_FUNC(user) +{ + /* maintain backwards compatibility */ + if (PSF(create_sid) != NULL) { + zval *args[1]; + char *id = NULL; + STDVARS; + + retval = ps_call_handler(PSF(create_sid), 0, NULL TSRMLS_CC); + + if (retval) { + if (Z_TYPE_P(retval) == IS_STRING) { + id = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + } + zval_ptr_dtor(&retval); + } + else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "No session id returned by function"); + return NULL; + } + + if (!id) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Session id must be a string"); + return NULL; + } + + return id; + } + + /* function as defined by PS_MOD */ + return php_session_create_id(mod_data, newlen TSRMLS_CC); +} + /* * Local variables: * tab-width: 4 |