Reputation: 668
I am working on a php script that sends data over to next page after a successful log in.
I got it to work 100% on my localhost
.
But now that I uploaded to a server, the variable isn't being passed over anymore.
Furthermore, I had to make changes to my PHP script because it wouldn't execute header("Location: blah.php)
.
After some research I found that ob_start()
fixed the problem with the header.
I"m wondering if that is what caused my $_SESSION
to not send data over to the next page.
Here is the code for the first page:
if (mysqli_num_rows($result) == 1){
$_SESSION['currentUser'] = $username;
header("Location: loggedin.php");
And this is the second page where I get the session variable currentUser
.
//start the session
session_start();
//grab the current user
$currentUser = $_SESSION['currentUser'];
echo "You're Logged in as: ". $currentUser;
When i run the script, it only prints out You're Logged in as:
with no username.
Upvotes: 0
Views: 117