Change your code to this please and then try :)
function chklogin()
{
require('script/session.php');
if(isset($username))
{
echo "welcome ".$username;
}
else
{
header('Location: /index.php');
}
}
chklogin();