summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArpad Ray <arpad@php.net>2011-08-29 21:29:26 +0000
committerArpad Ray <arpad@php.net>2011-08-29 21:29:26 +0000
commit1a2c15f912e05cbf673b9bfc091d77c857f5a31b (patch)
tree165c9b3d51a4d6f606fafddf73e2b4a026082253
parent53bfe7648949f64e90b2402d7ff5609a98cade51 (diff)
downloadphp-git-1a2c15f912e05cbf673b9bfc091d77c857f5a31b.tar.gz
Expose session status via new function, session_status (Req #52982)
-rw-r--r--ext/session/session.c18
-rw-r--r--ext/session/tests/session_status.phpt24
-rw-r--r--ext/session/tests/session_status_disabled.phpt17
3 files changed, 59 insertions, 0 deletions
diff --git a/ext/session/session.c b/ext/session/session.c
index 89a3aca415..d511a462fe 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1830,6 +1830,18 @@ static PHP_FUNCTION(session_write_close)
}
/* }}} */
+/* {{{ proto int session_status(void)
+ Returns the current session status */
+static PHP_FUNCTION(session_status)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_LONG(PS(session_status));
+}
+/* }}} */
+
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_session_name, 0, 0, 0)
ZEND_ARG_INFO(0, name)
@@ -1903,6 +1915,7 @@ static const zend_function_entry session_functions[] = {
PHP_FE(session_set_cookie_params, arginfo_session_set_cookie_params)
PHP_FE(session_get_cookie_params, arginfo_session_void)
PHP_FE(session_write_close, arginfo_session_void)
+ PHP_FE(session_status, arginfo_session_void)
PHP_FALIAS(session_commit, session_write_close, arginfo_session_void)
PHP_FE_END
};
@@ -2004,6 +2017,11 @@ static PHP_MINIT_FUNCTION(session) /* {{{ */
#endif
php_session_rfc1867_orig_callback = php_rfc1867_callback;
php_rfc1867_callback = php_session_rfc1867_callback;
+
+ REGISTER_LONG_CONSTANT("PHP_SESSION_DISABLED", php_session_disabled, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_SESSION_NONE", php_session_none, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_SESSION_ACTIVE", php_session_active, CONST_CS | CONST_PERSISTENT);
+
return SUCCESS;
}
/* }}} */
diff --git a/ext/session/tests/session_status.phpt b/ext/session/tests/session_status.phpt
new file mode 100644
index 0000000000..d1f7e2f386
--- /dev/null
+++ b/ext/session/tests/session_status.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test session_status() function : active, none
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+
+ob_start();
+
+echo "*** Testing session_status() : active, none\n";
+
+var_dump(PHP_SESSION_NONE != PHP_SESSION_ACTIVE);
+var_dump(session_status() == PHP_SESSION_NONE);
+
+session_start();
+
+var_dump(session_status() == PHP_SESSION_ACTIVE);
+
+?>
+--EXPECTF--
+*** Testing session_status() : active, none
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/session/tests/session_status_disabled.phpt b/ext/session/tests/session_status_disabled.phpt
new file mode 100644
index 0000000000..24e0ecd7bf
--- /dev/null
+++ b/ext/session/tests/session_status_disabled.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test session_status() function : disabled
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+session.save_handler=non-existant
+--FILE--
+<?php
+
+echo "*** Testing session_status() : disabled\n";
+
+var_dump(session_status() == PHP_SESSION_DISABLED);
+
+?>
+--EXPECTF--
+*** Testing session_status() : disabled
+bool(true)