_SESSION variables and Bad connections
Posted: Tue Dec 07, 2010 9:41 pm
I have a site that uses a mysql connection to login and then set the $_SESSION variables. Long story short, every thing works. However, on bad (read:high ping) internet connections the session variables would vanish. You could log in, all the variables would set (you could read them via a debug link) and everything was fine, and you could do this indefinitely. But, if you stopped navigating for a minute or so...POOF no more session variables.
After guessing at the problem (client/server connection timing out and server clearing the variables)
I solved it with a javascript function that looks (more or less) like this:
function live(){
l=the_ajax_load_function_I_use("blank.php");
live_timer=setTimeout("live()",10000);
}
window.onload = function(){
//otherstuff
live();
}
In other words, I call my ajax loader which reads a php file off the server, that returns null, every ten seconds. Thus the connection to the server is kept 'live.'
And yes, this works.
However, it is ugly as hell. Can anyone point me to a better idea (preferable not using cookies and preferable server side?)
Thanks-
After guessing at the problem (client/server connection timing out and server clearing the variables)
I solved it with a javascript function that looks (more or less) like this:
function live(){
l=the_ajax_load_function_I_use("blank.php");
live_timer=setTimeout("live()",10000);
}
window.onload = function(){
//otherstuff
live();
}
In other words, I call my ajax loader which reads a php file off the server, that returns null, every ten seconds. Thus the connection to the server is kept 'live.'
And yes, this works.
However, it is ugly as hell. Can anyone point me to a better idea (preferable not using cookies and preferable server side?)
Thanks-