php $_SESSION restableciendo cada 10 segundos

El problema que tengo es este:

I'm setting a page number with php $_SESSION['page'] at the top of my 'home' page, then using Jquery to retrieve data from a php file using the $_SESSION['page'] for reference, and updating $_SESSION['page'] so that on the next call to the file i know where to pick up from...

However, every 10 seconds, the $_SESSION['page'] reverts to what i set it at originally on the 'home' page..? Here is the basic example.

'Home' page:

<!DOCTYPE html>
    <meta charset='utf-8'>
    function get_stories(){
        $.post("function.php", function(data){
    <button onmouseup="get_stories();">Get Stories</button>
    <div id="stories"></div>

The function.php:

$page = $_SESSION['page'];

//does some REALLY simple sql calls nothing editing the $_SESSION in anyway.
//formats the results and puts them in a variable $string

if(strlen($string)>0){ //if there was content

print $string;


Every ten second however.. my $_SESSION['page'] reverts back to 1 (what i set it as when my 'Home' page first opens).

I even made a test where all the function did was increment the $_SESSION['page'] and is still reverted every ten second...

preguntado el 27 de noviembre de 13 a las 06:11

Have you verified you're sending the correct cookie/SID? You might get an entirely new session each call. -

I believe so. The function is working properly and incrementing the $_SESSION['page'] just fine for the ten seconds. However just any $_SESSION variable that i set in the 'home' page revert back every ten seconds.. -

Easy to check: print SID to a log (or the page) and verify. You still might have a cookie lifetime of 10s or something. -

That also doesn't seem to be the issue... My 'session.cookie_lifetime' is set to '0' Meaning it dies when the browser closes. All sessions set when the user logs in and such are fine. just this variable that is reset each time the visiter revisits the 'home' page reverts during the jquery call. its as if the jquery $.post() function is refreshing the page every ten seconds... -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.