PHP Sessions (4 posts)

  1. Madmax
    Posted 11 years ago #

    I have a script i currently use to create a photo gallery. here:
    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:
    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.

  2. Jabbok
    Posted 11 years ago #

    Perhaps you need to place the entire address before "login.php".

  3. 71m
    Posted 11 years ago #

    Hey, I am currently trying to install an alicebot on my site and having very similar probs.
    I think it has something to do with having two sessions at the same time....
    I got rid of the alice bots user session which now allows it to work,
    I have also added the wordpress id of registered users to the alice bot.
    However I am having troubles working out how to display the wordpress session id.....

  4. kato
    Posted 11 years ago #

    in your php.ini file, change the session autostart value to zero.


    session.auto_start = 0

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.