I am creating a session checker that i want to use on my pages and I’ve run into an error.
I created a simple function file that i want to include on each page along with a password and username verifier. this is that file:
[code=php]function session_checker(){ if(!session_is_registered(‘first_name’)){ include ‘login_form.html’; exit(); } }
at the top of the page I put:
[code=php]include ‘check.php’; session_start(); session_checker();
i am getting the following error message when I go to the page without logging in:
Warning: session_start(): Cannot send session cookie – headers already sent by (output started at /home/cadence/public_html/secure/index2.php:3) in /home/cadence/public_html/secure/index2.php on line 5
here is a copy of index2.php:
<html>
<head>
[code=php]include ‘check.php’; session_start(); session_checker();
It does actually display the user login box AND the login box will actually log me in and take me to the page BUT the same warning message above appears at the top of the page when I do log in.
Can someone please help me sort this out? I’d also like to require a username and password check on each page so if anyone could tell me how to implement that I’d appreciate it.