1

I am creating a login page for a website using PHP. I added "session_start();" as seen below to start the session. Then I put the rest of the websites code below it (other php, html, etc). Whenever I use session_start, the program stops executing and shows a blank page. Also, the page displays error 500 on some browsers. I'm not sure if this is a permission problem.

How do I properly use session_start()? My code is below. When I run it it shows a blank screen. When I comment out session_start(); it prints "Working...".

<?php 
session_start();
echo "Working...";
?>
SamMachine
  • 31
  • 1
  • 6
  • Looks like this question to me: https://stackoverflow.com/questions/10601556/weird-issue-putting-session-start-causes-pages-not-to-load – Berko Nov 08 '20 at 22:48
  • 1
    500 errors are recorded in the server error log, you need to check it to find out the cause of the error – Lawrence Cherone Nov 08 '20 at 23:17

1 Answers1

0

Ok I figured it out. Thanks for the help everyone. After looking at the logs the error read Fatal error: Uncaught Error: Call to undefined function session_start() in /usr/local/www/apache24/data/test.php:2 Stack trace: #0 {main} thrown in /usr/local/www/apache24/data/test.php on line 2

All I had to do was install some packages (mod_php72 and php72-session) and restart the server.

These posts really helped: Call to undefined function session_start() https://forums.freebsd.org/threads/call-to-undefined-function-session_cache_limiter.69010/

SamMachine
  • 31
  • 1
  • 6