123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- function session_test_menu() {
- $items['session-test/get'] = array(
- 'title' => 'Session value',
- 'page callback' => '_session_test_get',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/id'] = array(
- 'title' => 'Session ID',
- 'page callback' => '_session_test_id',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/id-from-cookie'] = array(
- 'title' => 'Session ID from cookie',
- 'page callback' => '_session_test_id_from_cookie',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/set/%'] = array(
- 'title' => 'Set session value',
- 'page callback' => '_session_test_set',
- 'page arguments' => array(2),
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/no-set/%'] = array(
- 'title' => 'Set session value but do not save session',
- 'page callback' => '_session_test_no_set',
- 'page arguments' => array(2),
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/set-message'] = array(
- 'title' => 'Set message',
- 'page callback' => '_session_test_set_message',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/set-message-but-dont-save'] = array(
- 'title' => 'Set message but do not save session',
- 'page callback' => '_session_test_set_message_but_dont_save',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/set-not-started'] = array(
- 'title' => 'Set message when session is not started',
- 'page callback' => '_session_test_set_not_started',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items['session-test/is-logged-in'] = array(
- 'title' => 'Check if user is logged in',
- 'page callback' => '_session_test_is_logged_in',
- 'access callback' => 'user_is_logged_in',
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- function session_test_boot() {
- header('X-Session-Empty: ' . intval(empty($_SESSION)));
- }
- function _session_test_get() {
- if (!empty($_SESSION['session_test_value'])) {
- return t('The current value of the stored session variable is: %val', array('%val' => $_SESSION['session_test_value']));
- }
- else {
- return "";
- }
- }
- function _session_test_set($value) {
- $_SESSION['session_test_value'] = $value;
- return t('The current value of the stored session variable has been set to %val', array('%val' => $value));
- }
- function _session_test_no_set($value) {
- drupal_save_session(FALSE);
- _session_test_set($value);
- return t('session saving was disabled, and then %val was set', array('%val' => $value));
- }
- function _session_test_id() {
-
-
- $_SESSION['test'] = 'test';
- drupal_session_commit();
- return 'session_id:' . session_id() . "\n";
- }
- function _session_test_id_from_cookie() {
- return 'session_id:' . $_COOKIE[session_name()] . "\n";
- }
- function _session_test_set_message() {
- drupal_set_message(t('This is a dummy message.'));
- print t('A message was set.');
-
-
-
- }
- function _session_test_set_message_but_dont_save() {
- drupal_save_session(FALSE);
- _session_test_set_message();
- }
- function _session_test_set_not_started() {
- if (!drupal_session_will_start()) {
- $_SESSION['session_test_value'] = t('Session was not started');
- }
- }
- function session_test_user_login($edit = array(), $user = NULL) {
- if ($user->name == 'session_test_user') {
-
-
- exit;
- }
- }
- function session_test_form_user_login_alter(&$form) {
- $form['#https'] = TRUE;
- }
- function session_test_drupal_goto_alter(&$path, &$options, &$http_response_code) {
- global $base_insecure_url, $is_https_mock;
-
-
-
- if (!empty($is_https_mock)) {
- $path = $base_insecure_url . '/' . $path;
- }
- }
- function _session_test_is_logged_in() {
- return t('User is logged in.');
- }
|