Jump to content

Recommended Posts

im on a host server and  i cant access the php.ini file to change the session's... after around 30/40 min of users not been active the sessions expire...

 

the problem is if a user is still on the page when the sessions expire and they make a post in the forum then they can still post it but obviusly as the sessions have ran out then only the post is made and the username ect is blank!

this also effects how i track users on pages as if they refresh the page when they are on it then it records them as blank and i get an output of e.g  admin,, (inbetween ,, is nothing as the person on the page has no sessions to record there user name)

 

so what can u guys suggest?

Link to comment
https://forums.phpfreaks.com/topic/131179-sessions-keeps-logging-me-out/
Share on other sites

Where you submit the data. Before you do any processing of the data from the form, check if the session is set.

 

if(isset($_SESSION['username_session'])){
//process form
}else{
//redirect to login with message about inactivity
}

well basicly i log the users on my page via

 

function selfURL() { 
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; 
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); 
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } 
function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); }
$filename = (selfURL());
//Insert User
$insert = mysql_query("REPLACE INTO `useronline` SET `timestamp`='$timestamp', `ip`='".$_SERVER['REMOTE_ADDR']."', `file`='$filename',`user`='$username',`user_id`='".$_SESSION['user_id']."'") 
or die(mysql_error()); 

 

so if a users trys to access the page and is not logged in it saves it as "" (blank) but still records there info like ip ect..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.