I have a website that has fb login in it. When the login is successful then the user info is added to the header. But how would I maintain this information when the user is moving from one webpage to another?
Since PHP is tagged, i believe that you would be using PHP.
create a header.php
or whatever you want to name file which has the header information.
and include('header.php')
where ever it is required.
Doing this you will not have to repeat the code and maintain the same header
You need to use Cookies or PHP Sessions for that.
The Cookie will be saved on the Client from your User, so only javascript can work with it. But Users could disable Cookies or/and Javascript, so this is a "unsafe" option.
I'd rather do this with Sessions, these will be handled from the server where the php runs. You need to send the user data from the login to a php file with saves it in a session. Then you could render another HTML file and fill it with the data from the Session.
I believe you need session.
Initialize session at the time of when use login
Example:
<?php
session_start();//required with session
if (!isset($_SESSION['userId'])) {
//welcome user
} else {
//Register or login
}
?>
Details of Session Use
If you want to use same code for every page make individual file like header.php
and simply include this any where you want
include "header.php";
Details: Include PHP