Do I have to use htmlspecialchars() before inserting the Session variable back in the textbox?
If you want to insert into a textbox with jQuery, you need to store the value within the page somewhere. e.g.
<body data-text-value="<?php echo htmlspecialchars($_SESSION['text']) ?>">
Then to insert it into your text box using jQuery:
$('#textbox').val($('body').data('text-value'));