0

For some reason I've having problems reading this session variable within an ajax document, I've got this inside online.php:

` session_start();

if (isset($_SESSION['username'])) { $username = $_SESSION['username']; } `

For some Reason this is not setting username even when the session var is being used on the host page, i call on the php file every second using this

` $(document).ready(function() {

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

$("#stop").click(function() { clearInterval(refreshId); }); }); `

Am I doing something wrong, or is this not even possible?? Any advice would really help thanks alot!

2 Answers 2

2

you have to send response for ajax request as json array. after that - you can use it.

here is the sample googled tutorial: http://viralpatel.net/blogs/2009/04/jquery-ajax-tutorial-example-ajax-jquery-development.html

ps: i wonder that you didn't ever look what was returned back from server for your ajax request.

Sign up to request clarification or add additional context in comments.

1 Comment

hmm very interesting zerkms, well the problem was that i had forgotten that I had changed my session var to memberName instead of username thats why it didn't work... So it's my fault, sorry to have wasted your time. It's working perfectly without json, so obviously thats not necessary, thank you
0

I had changed my session var to memberName

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.