PHP Session Problem in Private Browsers

Status
Not open for further replies.

datasync

New Member
Messages
16
Reaction score
0
Points
1
I'm developing an analytics script that people will be able to add to their page in order to track visitor data. One of the issues I've come across is devising a way to track individual's sessions when they're viewing someone's page from a private browser (I.e. Incognito).

This is the script I'm using to see if someone to observe if someone has been active for more than 30 minutes, if they have, a new session will be created, if not, then they will resume their previous session.

PHP:
session_start();
$max_time =1800;
$current = time();if(!isset ($_SESSION['Stationary'])){
$_SESSION['Stationary']= time();
$session = $_SESSION['Stationary'];}if(!isset ($_SESSION['Inactive'])){
$_SESSION['Inactive']= time();}else{
$session_life = $current - $_SESSION['Inactive'];if($session_life > $max_time ){
session_destroy();
session_start();
$_SESSION['Inactive']= time();
$_SESSION['Stationary']= time();
$session = $_SESSION['Stationary'];}else{
$_SESSION['Inactive']= time();
$session = $_SESSION['Stationary'];}}

This script works flawlessly when a user views my page from a regular browser (IE. Chrome Incognito), however when they view it on something like an iPhone, in Private Browsing, every time they access a new page, a new session is rendered -- a problem that I do not have when viewed otherwise.

So my question then is, I'm aware that viewing pages in a Private Browser is achieved through temporary cacheing which is cleared once the browser is closed, however why is it that even when the browser is not closed, opening a link destroys their previous session even when the link leads to another page, with the same script on the page?

Is there a workaround to this?

EDIT: I should note that this script is being placed in a php file with the header application/json to be used as a JavaScript file as well.
 

AngusThermopyle

Active Member
Messages
319
Reaction score
52
Points
28
Sessions are tracked by ID
ID's are tracked two ways.
1. Cookies -- which can be turned off by the user
2. URLs -- which cannot be turned off but makes URLs very messy

Apparently php.ini (sever wide, will not be adjusted by admins -- don't bother asking) turns cookies on for sessions, but urls off.

Not sure if you can use .htaccess to turn on the url feature for your account. Or if calling ini_set() in your script helps.

You might want to Google session.use_trans_sid and session.use_only_cookies
 
Status
Not open for further replies.
Top