Skip to content Skip to sidebar Skip to footer

Session Variable Not Passed In Live Server

I have tried out some code in php for user registration this whole code works fine on local server but when it comes to live server every php code is getting executed but session v

Solution 1:

You have space before declaring session variable.

<?php
session_start();
?>

Note the space before <?php. This will create an issue so just remove it.

Solution 2:

The session_start() function must be the very first thing in your document. Before any HTML tags. Try this:

<?php
  session_start();
?>
<!DOCTYPE html><html><body>

Solution 3:

You have saved the fullName as $_SESSION["user"]["fullname"] :

$_SESSION["user"]["fullname"] = $user["fullname"];

But you are echoing this way:

echo$_SESSION["fullname"];

Fix it to echo the correct one:

echo$_SESSION["user"]["fullname"];

Note: You can use additional check if(isset($_SESSION["user"]["fullname"])) so that you don't get error, when it is not actually set. But that will fix nothing until you use the correct variable / key.

Post a Comment for "Session Variable Not Passed In Live Server"