Skip to content

Commit 1c47c2d

Browse files
committed
added appserver_session_init function
1 parent 9b39c14 commit 1c47c2d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/appserver.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "php.h"
2727
#include "php_ini.h"
2828
#include "ext/standard/info.h"
29+
#include "ext/session/php_session.h"
2930
#include "php_appserver.h"
3031
#include "TSRM.h"
3132
#include "SAPI.h"
@@ -57,6 +58,7 @@ const zend_function_entry appserver_functions[] = {
5758
PHP_FE(appserver_set_raw_post_data, NULL)
5859
PHP_FE(appserver_get_http_response_code, NULL)
5960
PHP_FE(appserver_get_envs, NULL)
61+
PHP_FE(appserver_session_init, NULL)
6062
PHP_FE_END
6163
};
6264

@@ -329,6 +331,33 @@ PHP_FUNCTION(appserver_set_raw_post_data)
329331

330332
}
331333

334+
/* {{{ proto boolean appserver_session_init()
335+
init session state at runtime ... /* }}} */
336+
PHP_FUNCTION(appserver_session_init)
337+
{
338+
339+
if (PS(http_session_vars)) {
340+
zval_ptr_dtor(&PS(http_session_vars));
341+
PS(http_session_vars) = NULL;
342+
}
343+
/* Do NOT destroy PS(mod_user_names) here! */
344+
if (PS(mod_data) || PS(mod_user_implemented)) {
345+
zend_try {
346+
PS(mod)->s_close(&PS(mod_data) TSRMLS_CC);
347+
} zend_end_try();
348+
}
349+
if (PS(id)) {
350+
efree(PS(id));
351+
}
352+
353+
PS(id) = NULL;
354+
PS(session_status) = php_session_none;
355+
PS(mod_data) = NULL;
356+
PS(mod_user_is_open) = 0;
357+
/* Do NOT init PS(mod_user_names) here! */
358+
PS(http_session_vars) = NULL;
359+
}
360+
332361
/* {{{ proto boolean appserver_redefine(string $constant [, mixed $value])
333362
redefine/undefine constant at runtime ... /* }}} */
334363
PHP_FUNCTION(appserver_redefine)

src/php_appserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PHP_FUNCTION(appserver_redefine);
7474
PHP_FUNCTION(appserver_set_raw_post_data);
7575
PHP_FUNCTION(appserver_get_http_response_code);
7676
PHP_FUNCTION(appserver_get_envs);
77+
PHP_FUNCTION(appserver_session_init);
7778

7879
ZEND_BEGIN_MODULE_GLOBALS(appserver)
7980
appserver_llist *headers;

0 commit comments

Comments
 (0)