Hello all,
I make an AJAX request to see if a sesion variable has been set. I make a GET request to this script:
<?php session_start();
while(true){
if(isset($_SESSION['screen_name'])){
return true;
break;
}
}
?>
Clearly there are problems with this script and I wanted to solve these problems such as the continuous checking and waste of resources.
Scenario: I am trying to implement the oAuth method that twitgoo have used. You click "sign in" and then a window pops up for you to sign in to twitter. If you are successful, twitter redirects to a call back URL (which I guess sets session info) and the window is closed. Once this is done your message is posted to twitter. I am trying to achieve this and I am nearly there but I am unsure of my script above.
I would appreciate any help in making this script not so wasteful and if you have a better implementation, I would love to hear it.
Thanks all
Update
I have been give two good options which do you think is more efficient between:
1) Polling the server every few seconds using JS instead of the while loop eating up CPU cycles
2) Keep the while loop but "ease up" on the level of checking meaning no more http requests will be wasted