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
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
Share on other sites

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.