Skip to content

Instantly share code, notes, and snippets.

@Stiofan
Created July 11, 2017 09:59
Show Gist options
  • Save Stiofan/b7dc95866a6d45847ae90fc6bc9c9a3c to your computer and use it in GitHub Desktop.
Save Stiofan/b7dc95866a6d45847ae90fc6bc9c9a3c to your computer and use it in GitHub Desktop.
Test Sessions
<?php
// Set error reporting to display all errors and notices
error_reporting(E_ALL);
// Start a session
session_start();
// Check for the existence of a known session variable
if (isset($_SESSION['test_value'])) {
_e('Test value (should increase by 1 on each page refresh): '); echo $_SESSION['test_value'];
$_SESSION['test_value']++;
} else {
_e('No session exists - writing to test_value, refresh to check.');
$_SESSION['test_value'] = 1;
}
// Close and write session
session_write_close();
$foldername = session_save_path();
if (is_writable($foldername)) {
echo '<br>The Sessions folder is writable';
} else {
echo '<br>The Sessions folder is not writable';
}
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment