Jump to content

Sessions


ngreenwood6

Recommended Posts

I was told by someone to use the session set save handler. I do not know how to use this function. Basically I am trying to prevent users from logging in from the same ip address. I want to do it with the mysql database and I have it working. However it only works if the user ends the session with the logout page. If they just close the window and dont log out it doesnt get changed in the database. So someone told me to use the session set save handler. I was hoping that someone could give me an example of how to use this function as I have googled it and can find no good resources or tutorials. If you know of an easier/better way please explain. Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/123832-sessions/
Share on other sites

I found this.  I don't know if it helps though.

 

// session garbage collection:

function mysql_sess_gc ($sess_maxlife)

{

global $mysql_sess_conn_id;

 

$time=date("format_of_date_used_in_t_column",now()-$sess_maxlife);

 

$query="SELECT * FROM sessions WHERE t<'$time' "; $r=mysql_query($query,$mysql_sess_conn_id);

for ($i=0; $i<mysql_numrows($r); $i++) {

// here you store sessions in saved_sessions table

 

}

    $query = "DELETE FROM sessions WHERE t < '$time' ",

    mysql_query ($query, $mysql_sess_conn_id);

   

return;

}

 

Link to comment
https://forums.phpfreaks.com/topic/123832-sessions/#findComment-639377
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.