accessing php session variable
Posted: Fri May 23, 2014 4:23 pm
Hi everyone.
I need to access a php session variable, so that when a button is clicked, the session variable is passed to the textarea. the text area is a tinymce editor.
I can pass the variable from one textarea to another, but i would prefer not to do it that way. this is my code so far. Any help would be appreciated. Thanks.
Add Signature to Message <input type="button" value="ADD" onclick="addtext();" />
Currently nothing happens when I click the button. if i replace var signature = '<?php $_SESSION['SESS_USERS_SIG']; ?>'; with var signature = 'TEST'; The word test appears in the tinymce editor, so I know the coding works with static text. I just can't seem to reference a php session variable correctly.
I need to access a php session variable, so that when a button is clicked, the session variable is passed to the textarea. the text area is a tinymce editor.
I can pass the variable from one textarea to another, but i would prefer not to do it that way. this is my code so far. Any help would be appreciated. Thanks.
Code: Select all
<script language="javascript" type="text/javascript">
function addtext() {
var signature = '<?php $_SESSION['SESS_USERS_SIG']; ?>';
var newtext = "<br /><br />" + signature;
tinymce.get('reply').execCommand('mceInsertContent',true, newtext); // adds the content at the carat postion
}
</script>
Currently nothing happens when I click the button. if i replace var signature = '<?php $_SESSION['SESS_USERS_SIG']; ?>'; with var signature = 'TEST'; The word test appears in the tinymce editor, so I know the coding works with static text. I just can't seem to reference a php session variable correctly.