javascript get _session
javascript:
$(document).ready(function(){ var session; var secpic=document.getElementById('secpic'); $.ajaxSetup({cache:false}) $.get('gs.php',{requested:'captcha'},function (data) { session=data; secpic.value=$.trim(session); }); });
php:
session_start(); if (isset($_GET['requested'])) { print $_SESSION[$_GET['requested']]; } else { print json_encode($_SESSION); }
html:
<input type="hidden" id="secpic" name="secpic" value=""/>
http://stackoverflow.com/questions/2765175/how-to-get-session-variables-from-php-server-with-ajax-function-php-html-js-aj