Hi, I am trying to fetch username from session variable of one php page to another php page.

This below code fetch username from login page
<?php

    $uname = $_GET['uname'];


@session_start();
if($_SESSION[$uname])
{

?>.... //Remaining Code

When I click submit button to go to my next php page I want the same username to be dispalyed again.
How can I achieve this?

First store the username in the session variable.

// sanitize/validate first
//...
$_SESSION[$uname] = $uname;

On other pages (within the same session) it will be available to your scripts:

$uname = $_SESSION[$uname];

provided that you used the session_start() (always put it on top of your script).

And sanitize the user input first using appropriate method depending on where are you using the data (database, email, html, url, javascript...).

Thank You!! Its Working..
added session_start().

Cool. If this answers your question please mark the thread as solved. Happy coding.