From: Mark L. Woodward Date: Sun, 24 Mar 2002 17:54:19 +0000 (+0000) Subject: Added support for session manager ID creation, works with patch submitted earlier X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~1062 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4211c9fed246196b3ccb43743cccc52777725670;p=php Added support for session manager ID creation, works with patch submitted earlier --- diff --git a/ext/msession/msession.c b/ext/msession/msession.c index 2b259ec577..383ee25bdf 100644 --- a/ext/msession/msession.c +++ b/ext/msession/msession.c @@ -23,6 +23,7 @@ #include "ext/standard/info.h" #include "ext/session/php_session.h" +#define ERR_DEBUG /* Macros and such */ #ifndef TRUE @@ -31,6 +32,9 @@ #ifndef FALSE #define FALSE 0 #endif +#ifndef SID_LEN +#define SID_LEN 32 +#endif #ifdef ERR_DEBUG #define ELOG( str ) php_log_err( str ) @@ -77,13 +81,19 @@ #if HAVE_MSESSION #ifdef HAVE_PHP_SESSION +#ifdef HAVE_PHP_SESSION_CREATESID /* If the PHP Session module is compiled or available, include support */ +PS_FUNCS_SID(msession); +ps_module ps_mod_msession = { + PS_MOD_SID(msession) +}; +#else PS_FUNCS(msession); - ps_module ps_mod_msession = { PS_MOD(msession) }; #endif +#endif /* Static strings */ static char s_szNoInit[]="Msession not initialized"; @@ -250,8 +260,10 @@ char *PHPMsessionGetData(const char *session) if(s_reqb->req.stat==REQ_OK) ret = safe_estrdup(s_reqb->req.datum); +#if 0 // If there is a session, there may no be data yet, which is valid. else if(s_reqb->req.param != REQE_NOSESSION) php_error(E_WARNING, s_szErrFmt, ReqErr(s_reqb->req.param)); +#endif IFCONNECT_ENDVAL(0) return ret; @@ -1151,6 +1163,31 @@ PS_GC_FUNC(msession) ELOG( "ps_gc_msession"); return SUCCESS; } + +#ifdef HAVE_PHP_SESSION_CREATESID +PS_CREATESID_FUNC(msession) +{ + if(s_reqb && s_conn) + { + ELOG("Should create a new session"); + FormatRequest(&s_reqb, REQ_UNIQ,"", "", "",SID_LEN); + DoRequest(s_conn, &s_reqb); + + if(s_reqb->req.stat==REQ_OK) + { + if(newlen) + *newlen = SID_LEN; + return safe_estrdup(s_reqb->req.datum); + } + else + { + php_error(E_WARNING, s_szErrFmt, ReqErr(s_reqb->req.param)); + } + } + ELOG("Yikes, could not get sid from msession"); + return php_session_create_id(mod_data, newlen TSRMLS_DC); +} +#endif /* HAVE_PHP_SESSION_CREATESID */ #endif /* HAVE_PHP_SESSION */ #endif /* HAVE_MSESSION */