cvs: php4 /ext/msession msession.c
| From: | Mark L. Woodward | Date: | Sun, 24 Mar 2002 17:54:19 +0000 |
| Subject: | cvs: php4 /ext/msession msession.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10655@lists.php.net to get a copy of this message | ||
mlwmohawk Sun Mar 24 12:54:19 2002 EDT
Modified files:
/php4/ext/msession msession.c
Log:
Added support for session manager ID creation, works with patch submitted earlier
Index: php4/ext/msession/msession.c
diff -u php4/ext/msession/msession.c:1.27 php4/ext/msession/msession.c:1.28
--- php4/ext/msession/msession.c:1.27 Fri Mar 1 07:01:38 2002
+++ php4/ext/msession/msession.c Sun Mar 24 12:54:18 2002
@@ -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 @@
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 @@
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 */