Using Session Variables inside an ajax document -


For any reason, I'm having trouble reading this session variable inside the AJAX document, let me know it online.

`session_start ();

If (isset ($ _ session ['username'])) {$ username = $ _SESSION ['username']; } `

This username is not set for some reasons, when I use session var on the host page, I call it a php file every time.

< P> `$ (document) .ready (function () {

var refreshId = setInterval (function () {$ ('# timeval'). Load ('online.php');}, 1000 );

$ ("#stop"). Click (function () {clear interval (refresh id);}}}}); `

Am I doing something wrong, or is it not even possible? Thank you very much any advice really!

You have to send an answer for AJAX request as json array. After that - you can use it.

Here's a sample tutorial:

ps: I'm surprised that you have never seen that your AJAX was returned from the server for the request.


Comments