PHP Sessions
-
Ok,
I have a script i currently use to create a photo gallery. here:
https://opencast.com.au/talent/home.php
At the top of my code i’ve started it with session start(); and works fine. but when i want to enter this in the php code section:
if (!$_SESSION[“valid_user”])
{
// User not logged in, redirect to login page
header(“location: login.php”);
}
// Display logout link
echo “Sign-Out“;
i upload, test and i get this page:
https://opencast.com.au/talent/home.php?category_id=&parent_id=0&photo_id=2&countdisplay=1&start=0
The error i get is a:
Warning: Cannot modify header information – headers already sent by (output started at /home/o/openc/www/talent/home.php:5) in /home/o/openc/www/talent/photogallery/home.gallery.php on line 179
i check line 179 which is this from the code i entered above:
header(“location: login.php”);
/////////////////
The thing that confuses me is it seems to be trying to redo the session it already created after i click on one of the images and thus i get this error?
can somone help me out? how do you insert a session variable in the middle of the script that ultimatley visualy creates a new page from the same php script on the same page?
Basicly i want to create login after somone clicks on the image and then accesses that area.
- The topic ‘PHP Sessions’ is closed to new replies.