I am having difficulty in setting variables in a session, and then
accessing those variables throughout the web pages that they click
on. After having them set a user name and password, successfully
authenticating against Active Directory, I send them from the
login.php page to the index.php page. But when I get to the index.php
page, the session ID is visible, but the session variables and values
are not. Can you help me out? Also, I'm curious how to distinguish
between various sessions if multiple ones are available. My files are
below. Thanks.
Eddie
-- excerpt of login.php page
start_session() ;
$user= $_POST[u];
$pass= $_POST[p];
if (isset($_SESSIO N[user]) and ($_SESSION[user]==$user)){
$_SESSION[auth] = admin_all;
$_SESSION[user] = $user;
$_SESSION[timelast] = time();
$_SESSION[email] = 'testemail@test domain.com';
header('Locatio n: http://mydomain.com/index.php');
}
but when I go to the on to the index.php page, I cannot see the
results. What am I missing?
-- excerpt of index.php page
$sessname = session_name();
$sessid = session_id();
session_start() ;
print "<pre>\nContent s of \$_COOKIE:\n";
foreach ($_COOKIE as $k =$v) {
print " $k = $v\n";
}
print "\nContents of \$_SESSION:\n";
foreach ($_SESSION as $k =$v) {
print " $k = $v\n";
}
print "</pre><br>";
print "sessionuse r = " . $_SESSION[user] . " <br>";
print "sessiontimelas t = " . $_SESSION[timelast] . " <br>";
-- output of index.php page
Contents of $_COOKIE:
PHPSESSID = e12d796fc6e3735 69202c58d8f0968 15
Contents of $_SESSION:
user =
timelast =
Session name = PHPSESSID
Session id = e12d796fc6e3735 69202c58d8f0968 15
-- excerpt of php.ini file
session.use_coo kies = 1
session.name = PHPSESSID
session.auto_st art = 0
session.cookie_ lifetime = 0
session.seriali ze_handler = php
accessing those variables throughout the web pages that they click
on. After having them set a user name and password, successfully
authenticating against Active Directory, I send them from the
login.php page to the index.php page. But when I get to the index.php
page, the session ID is visible, but the session variables and values
are not. Can you help me out? Also, I'm curious how to distinguish
between various sessions if multiple ones are available. My files are
below. Thanks.
Eddie
-- excerpt of login.php page
start_session() ;
$user= $_POST[u];
$pass= $_POST[p];
if (isset($_SESSIO N[user]) and ($_SESSION[user]==$user)){
$_SESSION[auth] = admin_all;
$_SESSION[user] = $user;
$_SESSION[timelast] = time();
$_SESSION[email] = 'testemail@test domain.com';
header('Locatio n: http://mydomain.com/index.php');
}
but when I go to the on to the index.php page, I cannot see the
results. What am I missing?
-- excerpt of index.php page
$sessname = session_name();
$sessid = session_id();
session_start() ;
print "<pre>\nContent s of \$_COOKIE:\n";
foreach ($_COOKIE as $k =$v) {
print " $k = $v\n";
}
print "\nContents of \$_SESSION:\n";
foreach ($_SESSION as $k =$v) {
print " $k = $v\n";
}
print "</pre><br>";
print "sessionuse r = " . $_SESSION[user] . " <br>";
print "sessiontimelas t = " . $_SESSION[timelast] . " <br>";
-- output of index.php page
Contents of $_COOKIE:
PHPSESSID = e12d796fc6e3735 69202c58d8f0968 15
Contents of $_SESSION:
user =
timelast =
Session name = PHPSESSID
Session id = e12d796fc6e3735 69202c58d8f0968 15
-- excerpt of php.ini file
session.use_coo kies = 1
session.name = PHPSESSID
session.auto_st art = 0
session.cookie_ lifetime = 0
session.seriali ze_handler = php
Comment