Re: store session in database
This is how I resolved my situation. I did not want to let any user logon twice. Also users close the browser without logging off. So if another user is also logged in he will get a message as below.
So I store the session id in the users table. My user table has field called sessionid which varchar 32.
Then in the control login page just before redir I store the session_id into data base as below : ( OnValidate )
$sessionid = session_id();
sc_exec_sql ("update Staff set SessionID = '$sessionid' where Email = $var_login and Password = $var_password ");
sc_redir('treemenu');
I call this function from onScriptInit on every form. That’s not a bid deal as if you want to change the function you just do it once.
CheckLogin();
The function in the project library is as follows :
function CheckLogin()
{
sc_lookup(ds_user, “Select SessionID from Staff where Email = ‘[var_loginuser]’”);
$sessionid = session_id();
$dbsessionid = {ds_user [0] [0]};
if ($dbsessionid !== $sessionid)
{
?>
<SCRIPT LANGUAGE=“javascript”>
alert(“It appears you are already logged somewhere else. Please click Log Off and Log back in. MSG by Security Administrator”);
</SCRIPT>
<?php
sc_exit();
}
}
But it does exit the application.
I hope this helps someone. If your situation is different - then you may be able to adapt this concept.
Happy to clarify if not clear.