Reputation: 1491
I have two pages on my webapp, both accessable with the same domain. They are in different folders. Both use Sessions, but the second page cant access the session.
I cant realy understand why...
Here are the first lines of my site:
The page where I create create all session variables (the login.php
)
<!DOCTYPE html>
<?php
session_start();
ini_set("display_errors", 1);
...
...
The page where the session isnt transmitted to (the image.php
):
<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION['general_email']) || $_SESSION['orga_ang'] != 1) {
echo "<meta http-equiv='refresh' content='0; URL=login.php?
src=account.php'>";
die();
}
...
...
As I said, both sites are accessable under the same domain, but the site where I create the login is in a different folder, the route from the login.php
to the image.php
is ../assets/modules/images/showimage.php
Why cant I access the session variable in my image.php
?
oOn other pages I can access the $_SESSION variable, only on image.php
not.
Upvotes: 0
Views: 92
Reputation: 1
If you do not know what happens always you can use error reports function.
error_reporting(1)
BTW. Twat is this ?
echo "<meta http-equiv='refresh' content='0; URL=login.php?src=account.php'>";
Mean:
?src=account.php
Upvotes: 0
Reputation: 4180
Remove any output before session_start() in image php
<?php
session_start();
?>
<!DOCTYPE html>
<?php
if(!isset($_SESSION['general_email']) || $_SESSION['orga_ang'] != 1) {
echo "<meta http-equiv='refresh' content='0; URL=login.php? src=account.php'>";
die();
}
...
Upvotes: 1
Reputation: 5191
You must call session_start before any other output including your doctype statement. Change
<!DOCTYPE html>
<?php
session_start();
to
<?php
session_start();
?>
<!DOCTYPE html>
Upvotes: 2