Hello again.
This thread is the continuing of the "Passing variables with Sessions".
The problem there was i couldn't pass variables with sessions and (as it was discovered thanks to Dalecosp. Also thanks to NogDog, bradgrafelman, stolzyboy, Bunkermaster) because of my Zone Alarm firewall.
The problem here is Zone Alarm firewall. (ZoneAlarm Pro version:5.5.062.011)
It blocks the session cookies, unless the Cookie Control and the Add Blocking levels at Privacy|Main dialog are set both to OFF! thus, leaving my privacy totally unprotected:eek:
For everyone who doesn't want to go through the entire thread "Passing variables with Sessions" in order to get the point of the subject, i'll summatize it:
[INDENT]My current session settings:[/INDENT]
session.auto_start 0
session.bug_compat_42 1
session.bug_compat_warn 1
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain
session.cookie_httponly
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure
session.entropy_file
session.entropy_length 0
session.gc_divisor 100
session.gc_maxlifetime 1440
session.gc_probability 1
session.hash_bits_per_character 4
session.hash_function 0
session.name PHPSESSID
session.referer_check
session.save_handler files
session.save_path C:\php\sess\tmp
session.serialize_handler php
session.use_cookies 1
session.use_only_cookies 0
session.use_trans_sid 0
I have two files movie1.php and moviesite.php as shown below:
movie1.php:
<?php
// make sure there are no spaces or blank lines before the opening php tag
ini_set('display_errors', 1); //**********
error_reporting(E_ALL); //**********
session_start(); //**********
if(session_id() == '') //NogDog's
{ //testing code
echo "No session id created!!!"; //**********
exit; //**********
} //**********
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<html>
<head>
<title>Find my Favorite Movie!</title>
</head>
<body>
<?php
$myfavmovie = urlencode("Life of Brian");
echo "<a href='moviesite.php?favmovie=$myfavmovie'>";
echo "Click here to see information about my favorite movie!";
echo "</a>";
?>
<br><br>
</body>
<?php //*********
echo session_id(); //Dalecosp's
print_r($_SESSION); //testing
exit; //code
?> //*********
</html>
moviesite.php:
<?php
// make sure there are no spaces or blank lines before the opening php tag
ini_set('display_errors', 1); //**********
error_reporting(E_ALL); //**********
session_start(); //**********
if(session_id() == '') //NogDog's
{ //testing code
echo "No session id created!!!"; //**********
exit; //**********
} //**********
//check to see if user has logged in with a valid passsword
if ($_SESSION['authuser'] != 1) {
echo "Sorry, but you don't have permission to view this page.";
echo "<br><br>";
echo session_id(); //*******************
print_r($_SESSION); //Dalecosp's testing code
exit; //*******************
exit();
}
?>
<html>
<head>
<title>My Movie Site - <?php echo $_REQUEST['favmovie']; ?></title>
</head>
<body>
<?php
echo "Welcome to our site, ";
echo $_SESSION['username'];
echo "! <br>";
echo "My favorite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate = 5;
echo "My movie rating for this movie is: ";
echo $movierate;
?>
<br><br>
</body>
<?php //*********
echo session_id(); //Dalecosp's
print_r($_SESSION); //testing
exit; //code
?> //*********
</html>
After running movie1.php and after clicking the link to moviesite.php, i kept on getting these outputs:
page1(http ://localhost/movie1.php):
Click here to see information about my favorite movie!
ec245c937a43a0bab7fe6d03fd91ff73Array ( [username] => Joe12345 [authuser] => 1 )
and
page2(http ://localhost/moviesite.php?favmovie=Life+of+Brian):
Notice: Undefined index: authuser in C:\Program Files\Apache Software Foundation\Apache2.2\test\moviesite.php on line 13
Sorry, but you don't have permission to view this page.
3fd5b037806e3fecb9faa955dfdcb7daArray ( )
The session_id of the 2nd page was different of that of the 1st one and also empty. Something was blocking the session cookie of the 1st page to be transferred to the 2nd one.
That was because of ZoneAlarm. Only when Cookie Control and the Add Blocking levels at Privacy|Main dialog were both set to OFF, the session cookies were allowed and the desired correct outputs appeared:
page1(http ://localhost/movie1.php):
Click here to see information about my favorite movie!
53b571dde88d6f8fb49dd12671833ad2Array ( [username] => Joe12345 [authuser] => 1 )
and
page2(http ://localhost/moviesite.php?favmovie=Life+of+Brian):
Welcome to our site, Joe12345!
My favorite movie is Life of Brian
My movie rating for this movie is: 5
53b571dde88d6f8fb49dd12671833ad2Array ( [username] => Joe12345 [authuser] => 1 )
Very nice! The problem was solved. But the problem that came up is that the settings at Privacy|Main dialog that had to be applied (Cookie Control๐ฎFF, Add Blocking๐ฎFF) are applied on all the web sites. I tried to apply them only on the "localhost" (as it is the location that i'm testing my php files) and leave Cookie Control:Medium, Add Blocking:High for the rest of the websites but i didn't make it.
Before, you suggest me to change my firewall, please take a look at the three attached files (where i describe with red color what i did and why, and also placed side by side the images of the relevant Dialog Boxes).
What should i do?