Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created March 26, 2014 14:24
Show Gist options
  • Save anytizer/9784541 to your computer and use it in GitHub Desktop.
Save anytizer/9784541 to your computer and use it in GitHub Desktop.
https sessions tester
<?php
/**
* Script to test session data sharing in http and https versions
* Theme: session initiated by HTTP should be accessible to HTTPS and vice-versa
* http://localhost/https/session.php
* https://localhost/https/session.php
*/
session_start();
header('Content-Type: text/plain');
if(!isset($_SESSION['counter']))
{
$_SESSION['counter'] = 0;
}
++$_SESSION['counter'];
$is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on';
$https_status = ($is_https)?'ON':'OFF';
echo "
Counter: {$_SESSION['counter']}
HTTPS Status: {$https_status}
";
print_r($_SESSION);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment