err_type = E_ERROR;
}
- php_error_docref(NULL TSRMLS_CC, err_type, "Cannot find save handler %s", new_value);
+ /* Do not output error when restoring ini options. */
+ if (stage != ZEND_INI_STAGE_DEACTIVATE) {
+ php_error_docref(NULL TSRMLS_CC, err_type, "Cannot find save handler '%s'", new_value);
+ }
return FAILURE;
}
PS(mod) = tmp;
}
/* }}} */
-static PHP_INI_MH(OnUpdateTransSid) /* {{{ */
-{
- SESSION_CHECK_ACTIVE_STATE;
-
- if (!strncasecmp(new_value, "on", sizeof("on"))) {
- PS(use_trans_sid) = (zend_bool) 1;
- } else {
- PS(use_trans_sid) = (zend_bool) atoi(new_value);
- }
-
- return SUCCESS;
-}
-/* }}} */
-
static PHP_INI_MH(OnUpdateSerializer) /* {{{ */
{
const ps_serializer *tmp;
err_type = E_ERROR;
}
- php_error_docref(NULL TSRMLS_CC, err_type, "Cannot find serialization handler '%s'", new_value);
+ /* Do not output error when restoring ini options. */
+ if (stage != ZEND_INI_STAGE_DEACTIVATE) {
+ php_error_docref(NULL TSRMLS_CC, err_type, "Cannot find serialization handler '%s'", new_value);
+ }
return FAILURE;
}
PS(serializer) = tmp;
}
/* }}} */
+static PHP_INI_MH(OnUpdateTransSid) /* {{{ */
+{
+ SESSION_CHECK_ACTIVE_STATE;
+
+ if (!strncasecmp(new_value, "on", sizeof("on"))) {
+ PS(use_trans_sid) = (zend_bool) 1;
+ } else {
+ PS(use_trans_sid) = (zend_bool) atoi(new_value);
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */
{
/* Only do the safemode/open_basedir check at runtime */
{
zval **ppid;
zval **data;
- char *p;
+ char *p, *value;
int nrand;
int lensess;
PS(apply_trans_sid) = PS(use_trans_sid);
- if (PS(session_status) != php_session_none) {
- if (PS(session_status) == php_session_disabled) {
- char *value;
+ switch (PS(session_status)) {
+ case php_session_active:
+ php_error(E_NOTICE, "A session had already been started - ignoring session_start()");
+ return;
+ break;
+ case php_session_disabled:
value = zend_ini_string("session.save_handler", sizeof("session.save_handler"), 0);
-
- if (value) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot find save handler %s", value);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot find unknown save handler");
+ if (!PS(mod) && value) {
+ PS(mod) = _php_find_ps_module(value TSRMLS_CC);
+ if (!PS(mod)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot find save handler '%s' - session startup failed", value);
+ return;
+ }
}
- return;
- }
- php_error(E_NOTICE, "A session had already been started - ignoring session_start()");
- return;
- } else {
- PS(define_sid) = 1;
- PS(send_cookie) = 1;
+ value = zend_ini_string("session.serialize_handler", sizeof("session.serialize_handler"), 0);
+ if (!PS(serializer) && value) {
+ PS(serializer) = _php_find_ps_serializer(value TSRMLS_CC);
+ if (!PS(serializer)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot find serialization handler '%s' - session startup failed", value);
+ return;
+ }
+ }
+ PS(session_status) = php_session_none;
+ /* fallthrough */
+
+ default:
+ case php_session_none:
+ PS(define_sid) = 1;
+ PS(send_cookie) = 1;
}
lensess = strlen(PS(session_name));
if (name) {
if (memchr(name, '\0', name_len) != NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The save_path cannot contain NULL characters");
-
zval_dtor(return_value);
RETURN_FALSE;
}
{
/* skipping check for non-zero args for performance reasons here ?*/
php_session_start(TSRMLS_C);
+
+ if (PS(session_status) != php_session_active) {
+ RETURN_FALSE;
+ }
RETURN_TRUE;
}
/* }}} */
}
/* }}} */
-
/* {{{ proto void session_unset(void) U
Unset all registered variables */
static PHP_FUNCTION(session_unset)
}
ps_globals->http_session_vars = NULL;
}
-/* }}}*/
+/* }}} */
static PHP_MINIT_FUNCTION(session) /* {{{ */
{
DISPLAY_INI_ENTRIES();
}
-/* }}} */
+/* }}} */
zend_module_entry session_module_entry = {
STANDARD_MODULE_HEADER,
$_SESSION["bar"] = "Blah!";
$_SESSION["guff"] = 123.456;
var_dump($_SESSION);
-$encoded = "A2Zvb2k6MTIzNDU2Nzg5MDs=";
-var_dump(session_decode(base64_decode($encoded)));
+$encoded = "foo|i:1234567890;";
+var_dump(session_decode($encoded));
var_dump($_SESSION);
var_dump(session_destroy());
--EXPECTF--
*** Testing session_decode() : variation ***
-Warning: session_start(): Unknown session.serialize_handler. Failed to decode session object in %s on line %d
-bool(true)
-array(0) {
-}
+Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d
+bool(false)
+
+Notice: Undefined variable: _SESSION in %s on line %d
+NULL
array(3) {
[u"foo"]=>
int(1234567890)
Warning: session_decode(): Unknown session.serialize_handler. Failed to decode session object in %s on line %d
bool(true)
-array(3) {
- [u"foo"]=>
- int(1234567890)
- [u"bar"]=>
- unicode(5) "Blah!"
- [u"guff"]=>
- float(123.456)
-}
-bool(true)
-Done
+unicode(17) "foo|i:1234567890;"
+Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
+bool(false)
+Done