jave.web
jave.web

Reputation: 15032

Ajax request not renewing session?

On my website, when user is logged in, there is an AJAX request going on every ~20seconds, the requested PHP is working with sesssion (starts with session_start).

I thought that having the website opened + the "infinite" ajax requesting should keep the logged-in user logged-in.

However I got an echo from one of my users, that he gets logged-out after a longer while - how is this possible? Isn't ajax request respectively the requested PHP renewing the Session?

What might cause these logg-outs?

Thanks in advance.

Upvotes: 0

Views: 797

Answers (2)

Denat Hoxha
Denat Hoxha

Reputation: 945

According to this post, it could be because the browser is caching AJAX requests which could be resolved by including a $.ajaxSetup({ cache: false }) call before your request.

Upvotes: 1

Pwner
Pwner

Reputation: 771

Try putting something like this in your header

<?php
ini_set('session.gc_maxlifetime', 60 * 60); //ini_set('session.gc_maxlifetime', Mulpitplyer*Seconds);
session_start();
?>

Sessions can also drop off if the user has an "unstable" internet conection

Upvotes: 1

Related Questions