Login page:
<?php
session_start();
#echo session_id ();
$_SESSION["auth"]= "yes";
echo '<a href="Portaltest.php?t='.time().'">portal page link. Auth set to: {$_SESSION["auth"]}</a>';
?>
Portal page:
<?php session_start();
echo "auth = {$_SESSION["auth"] } <BR />";
echo session_id ();
?>
The auth
session is lost between the two pages somehow!
Edit
Here is a test url:
http://proserv01.services.lyris.com/NFPInsurance/UnsegmentedMemberReport/logintest.php
When trouble-shooting sessions, there are a few things I tend to do, but let's start with your code.
Here is an updated version of your page code so you actually see the value stored in $_SESSION['auth'] (your quotes were causing some trouble):
<?php
session_start();
$_SESSION["auth"] = "yes";
echo '<a href="Portaltest.php?t='.time().'">portal page link. Auth set to: ' . $_SESSION["auth"] . '</a>';
?>
Here is the updated version of the portal page, which removes the additional space after the closing curly bracket:
<?php
session_start();
echo "auth = {$_SESSION["auth"]} <BR />";
?>
Now, if you don't see the auth with these revisions, you can try:
I am unsure as to what the expected results are, yet I will submit this as an answer with explanations set inside PHP comments.
Give this a try:
<?php
session_start();
$_SESSION["auth"]= "yes";
// will echo: portal page link. Auth set to: yes
echo '<a href="Portaltest.php?t='.time().'">portal page link. Auth set to: ' . $_SESSION["auth"] . '</a>';
echo "<br>";
// will echo: auth = yes
echo "auth = {$_SESSION["auth"] } <BR />";
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.