Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/session/mod_user_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
if (PS(default_mod) == NULL) { \
php_error_docref(NULL, E_CORE_ERROR, "Cannot call default session handler"); \
RETURN_FALSE; \
} \
if (!PS(mod_user_internal)) { \
php_error_docref(NULL, E_CORE_ERROR, "Cannot call session handler from user script"); \
RETURN_FALSE; \
}

#define PS_SANITY_CHECK_IS_OPEN \
Expand Down
1 change: 1 addition & 0 deletions ext/session/php_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ typedef struct _php_ps_globals {
} mod_user_names;
int mod_user_implemented;
int mod_user_is_open;
int mod_user_internal;
const struct ps_serializer_struct *serializer;
zval http_session_vars;
zend_bool auto_start;
Expand Down
15 changes: 14 additions & 1 deletion ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static inline void php_rinit_session_globals(void) /* {{{ */
PS(session_status) = php_session_none;
PS(mod_data) = NULL;
PS(mod_user_is_open) = 0;
PS(mod_user_internal) = 0;
PS(define_sid) = 1;
PS(session_vars) = NULL;
ZVAL_UNDEF(&PS(http_session_vars));
Expand Down Expand Up @@ -2236,15 +2237,18 @@ static PHP_FUNCTION(session_start)
} ZEND_HASH_FOREACH_END();
}

PS(mod_user_internal) = 1;
php_session_start();

if (PS(session_status) != php_session_active) {
PS(mod_user_internal) = 0;
RETURN_FALSE;
}

if (read_and_close) {
php_session_flush(0);
}
PS(mod_user_internal) = 0;

RETURN_TRUE;
}
Expand All @@ -2258,7 +2262,10 @@ static PHP_FUNCTION(session_destroy)
return;
}

RETURN_BOOL(php_session_destroy() == SUCCESS);
PS(mod_user_internal) = 1;
ret = php_session_destroy();
PS(mod_user_internal) = 0;
RETVAL_BOOL(ret == SUCCESS);
}
/* }}} */

Expand All @@ -2283,23 +2290,29 @@ static PHP_FUNCTION(session_unset)
Write session data and end session */
static PHP_FUNCTION(session_write_close)
{
PS(mod_user_internal) = 1;
php_session_flush(1);
PS(mod_user_internal) = 0;
}
/* }}} */

/* {{{ proto void session_abort(void)
Abort session and end session. Session data will not be written */
static PHP_FUNCTION(session_abort)
{
PS(mod_user_internal) = 1;
php_session_abort();
PS(mod_user_internal) = 0;
}
/* }}} */

/* {{{ proto void session_reset(void)
Reset session data from saved session data */
static PHP_FUNCTION(session_reset)
{
PS(mod_user_internal) = 1;
php_session_reset();
PS(mod_user_internal) = 0;
}
/* }}} */

Expand Down