Empty PHP session variables -
i'm trying store variables server-side session variables stop having access them database time. when client-side scripts request common data server don't have make connection mysql time. i'm using php database access , echo data i'm not outputting html. client-side scripts call these php scripts using ajax , receive data back.
i'm not sure how use session variables in php however. i've called session_start() @ beginning of script , later assign value *$_session['var'] = $var*.
in script call session_start() again , use value assigned $_session['var']. doesn't seem working though, variables empty.
am using them correctly?
the code goes (the mysql calls have been checked , successful):
<?php session_start(); /* variables mysql... */ $_session['my_var'] = $var; ?> in file:
<?php session_start(); /* receive request variables... */ $data = array( 'var' => $_session['my_var'] ); $reply = json_encode($data); echo $reply; ?>
Comments
Post a Comment