Introduction
The following are some techniques that you can use to test and troubleshoot PHP sessions.
Procedure
PHP Info
Check the status of PHP sessions with a PHP Info file:
How to use a PHP Info file for troubleshooting PHP
PHP Session Code
Create the following PHP file in the document root of the domain and then visit it in your browser:
<?php // Start Session session_start(); // Show banner echo '<b>Session Support Checker</b><hr />'; // Check if the page has been reloaded if(!isset($_GET['reload']) OR $_GET['reload'] != 'true') { // Set the message $_SESSION['MESSAGE'] = 'Session support enabled!<br />'; // Give user link to check echo '<a href="?reload=true">Click HERE</a> to check for PHP Session Support.<br />'; } else { // Check if the message has been carried on in the reload if(isset($_SESSION['MESSAGE'])) { echo $_SESSION['MESSAGE']; } else { echo 'Sorry, it appears session support is not enabled, or your PHP version is too old. <a href="?reload=false">Click HERE</a> to go back.<br />'; } }
PHP Session Cookie via Dev Tools (Chrome)
Make sure that the cookie has been set in the browser:
1. Right click somewhere on the PHP page that you're trying to get a session for
2. Click Inspect Element
3. Click the Application Tab
4. Check for the PHP Session cookie in in the Cookie section
5. Reload the page and check for the cookie again