From what I understand, you're initiating a session and afterwards, you want to create a $_SESSION variable based on what someone types in the text area. Assuming you don't want the page to change when the user clicks preview (but you want to be able to use the $_SESSION variable in future situations) you'll need to use something like AJAX (as you mentioned). The easiest way I've found to accomplish something like this is to use jQuery and AJAX together.
Basically, you'll create a JavaScript function (using jQuery) to select whenever the preview button was clicked. It will look something like this. First we add the id within the input tag...
<input type="button" id="previewID" name="Preview" value="Preview Description">
Next we create the function in the javascript file...
$('#previewID').click(function() {
request = $.ajax({
url: "/form.php",
type: "post",
data: serializedData
});
});
form.php could simply be a form that checks to see if $_POST['ShortDescription'] exists, if it does, sanitize it and store it in $_SESSION['ShortDescription']. The "serializedData" is just the contents of the text area that is being passed. (which really is just passing the variable contents over the URL. For example, if ShortDescription = "HelloThere", the serialized data would be "ShortDescription=HelloThere
", which appends to the URL like...
"www.website.com/form.php?ShortDescription=HelloThere
"
Keep in mind that you would not typically manually set this though, that was just to show the concept. Use something like:
var serializedData = $form.serialize();
View this question for an example AJAX request.
Disclaimer: There may be a better way to accomplish this, but I figured I would offer one possibility since no one had answered yet!