0

I'm working through troubleshooting PHP sessions. I have the following code:

// 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 you PHP version is to old. <a href="?reload=false">Click HERE</a> to go back.<br />';
              }
           }

This code returns session support is not enabled. However, when running

phpinfo();

Sessions return true. enter image description here

So I'm not sure what I'm doing wrong or right. Is there a better/easier or more definitive way to test for sessions?

Here is the URL: https://tacnetusstage.wpengine.com/session.php

Lz430
  • 307
  • 2
  • 7
  • 16
  • 1
    Check your log for `Headers already sent` warnings and fix the cause. – Barmar Jun 16 '20 at 18:16
  • See https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – Barmar Jun 16 '20 at 18:17
  • Its always best to show us all the code, but only after you check the error logs – RiggsFolly Jun 16 '20 at 18:31
  • Thanks guys! I don't have anything else on that page honestly. The entire code of that page is above. I haven't seen any headers already sent errors. I'm adding the URL above. – Lz430 Jun 16 '20 at 18:51

0 Answers0