Can anyone explain how to make this code work?
echo \'Welcome \'
Generally speaking, to use the single quote inside a string that is using the single quote as delimiter, just escape the single quote inside the string
echo 'That\'s all, folks';
It's not clear what the purpose of your code is, though.
echo 'Welcome ';
As you are already using PHP code, is not necessary. If you are only trying to output the content of a session variable, then you can use
echo 'Welcome ' . $_SESSION['username'] . '';