$_SESSION error:Notice: Undefined offset: 0

Links for php scripts

Moderators: egami, macek, gesf

Post Reply

Wed Jan 04, 2017 9:01 pm

Hi sorry I am just a baby in PHP. I want to get the value of $_SESSION['username'] but it gives me this error : Notice: Undefined offset: 0. Please see my code below. Your help will be greatly appreciated. Thanks.



echo "There are {$session} current sessions!";
echo "<br />";
echo $_SESSION[0]; //I want an output "andrew" but it fails.


New php-forum User
New php-forum User
Posts: 167
Joined: Wed Jun 15, 2016 8:35 am

Thu Jan 05, 2017 1:52 am

To show the value, echo it :

Code: Select all

echo '<p>' . $_SESSION['username'] . '</p>';

Post Reply