Skip to content

Instantly share code, notes, and snippets.

@AlexR1712
Forked from lukas-buergi/checkSession.php
Last active November 1, 2022 01:43
Show Gist options
  • Save AlexR1712/ace734d63cb15cb5623b16660456d1ee to your computer and use it in GitHub Desktop.
Save AlexR1712/ace734d63cb15cb5623b16660456d1ee to your computer and use it in GitHub Desktop.

Revisions

  1. AlexR1712 revised this gist May 28, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion checkSession.php
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@
    break;
    case "check":
    session_start();
    if(isset($_SESSION['test']) and $_SESSION['test123'] == 'test') {
    if(isset($_SESSION['test']) and $_SESSION['test'] == 'test123') {
    echo "Sessions seem to work. :-)";
    }else{
    echo "Sessions don't seem to work. :-(";
  2. AlexR1712 revised this gist May 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion checkSession.php
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@
    break;
    case "check":
    session_start();
    if(isset($_SESSION['test']) and $_SESSION['test'] == 'test'){
    if(isset($_SESSION['test']) and $_SESSION['test123'] == 'test') {
    echo "Sessions seem to work. :-)";
    }else{
    echo "Sessions don't seem to work. :-(";
  3. @lukas-buergi lukas-buergi revised this gist Jun 26, 2012. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions checkSession.php
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,11 @@

    switch($_GET['action']) {
    case "start":
    session_start();
    $_SESSION['test']='test123';
    echo 'Test session probably started, if you don\'t see any errors. Go <a href="mySessionTest.php?action=check">check</a>!</br>';
    if(session_start() && $_SESSION['test']='test123'){
    echo 'Test session probably started successfully. Go <a href="mySessionTest.php?action=check">check</a>!</br>';
    }else{
    echo 'Starting a test session seems to have failed. Go <a href="mySessionTest.php?action=check">check</a>!</br>';
    }
    echo 'And some additional information:</br>';
    echo 'session.save_path : ' . ini_get('session.save_path') . '</br>';
    echo 'session.cookie_path : ' . ini_get('session.cookie_path') . '</br>';
    @@ -27,6 +29,7 @@
    echo "Test session deleted.";
    break;
    case "check":
    session_start();
    if(isset($_SESSION['test']) and $_SESSION['test'] == 'test'){
    echo "Sessions seem to work. :-)";
    }else{
  4. @lukas-buergi lukas-buergi revised this gist Jun 26, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion checkSession.php
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    ini_set( 'display_errors', 1);

    if(!isset($_GET['action'])){
    die('Param is missing. Look at the <a href="https://gist.github.com/">source</a>.');
    die('Param is missing. Look at the <a href="https://gist.github.com/2995743">source</a>.');
    }

    switch($_GET['action']) {
  5. @lukas-buergi lukas-buergi created this gist Jun 26, 2012.
    38 changes: 38 additions & 0 deletions checkSession.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    <?php

    error_reporting( E_ALL );
    ini_set( 'display_errors', 1);

    if(!isset($_GET['action'])){
    die('Param is missing. Look at the <a href="https://gist.github.com/">source</a>.');
    }

    switch($_GET['action']) {
    case "start":
    session_start();
    $_SESSION['test']='test123';
    echo 'Test session probably started, if you don\'t see any errors. Go <a href="mySessionTest.php?action=check">check</a>!</br>';
    echo 'And some additional information:</br>';
    echo 'session.save_path : ' . ini_get('session.save_path') . '</br>';
    echo 'session.cookie_path : ' . ini_get('session.cookie_path') . '</br>';
    echo 'session.name : ' . ini_get('session.name') . '</br>';
    break;
    case "delete":
    $_SESSION = array();
    if (ini_get("session.use_cookies")) {
    $params = session_get_cookie_params();
    setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly'] );
    }
    session_destroy();
    echo "Test session deleted.";
    break;
    case "check":
    if(isset($_SESSION['test']) and $_SESSION['test'] == 'test'){
    echo "Sessions seem to work. :-)";
    }else{
    echo "Sessions don't seem to work. :-(";
    }
    break;
    default: die("Hey, I told you to look at the source, idiot. :P");
    }
    ?>