store session in database

hi everyone.
Im just wondering about the store session in database features of scriptcase.
I enable the this wizard in deployment but the problem is
i dont know how to use it.

Is anybody here experience this one.

Many Many thanks

regards,
Ghulma

Re: store session in database

I not sure I understand your question.
If you are asking about SC store the session info into a DB instead of your client, then this is setup for security. The only way to “use” this would be to access the table to get the values.

I think this is related to SC and not your app itself, but you may be able to get some info if needed.

Regards,
Scott.

Re: store session in database

Thank you for reply scott.
Yeah i think your right. the setting about save session in db is not in app.
but when you enable it will show in deployment wizard.

what i want to do is something the user cannot login when that user account is already login.
so i just save the session in db to monitor if the user-account is currently login.
my solution for now is i just inject ajax code in my homepage that makes the user session alive in db…
is this the best solution in it. Thank you so much.

Re: store session in database

I think the AJAX(w/ callback) approach is your best bet.

Regards,
Scott.

Re: store session in database

Yes. i did that. as of now thats my solution.
I have manually php-code that saves session in db and ajax update it every min.

Anyway thank you for reply.

regard,
ghulma

Re: store session in database

You may want to change the check to when they perform an action or load another app instead of a timer. No need to cause unwanted traffic on your network.

Regards,
Scott.

Re: store session in database

Thank for idea scott,
really appriciate it.

regards,
ghulma

Re: store session in database

I would like to know how this works as well. As far as I understand you
can store the users session data in a table - you need this if you are going
to use multiple web servers connecting to a database server.

I would be useful for a tutorial.
Mark

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.

Re: store session in database

Hi. Are any of you doing this to allow you to run multiple webservers frontends into one db? I was thinking it could help with scalability as well as redundancy. As server load goes up just add frontends. Have them on multiple boxes.

Re: store session in database

@gringoloco
i use ession_set_save_handler() function of php…
[hr]

@onmountain
please elaborate
“As server load goes up just add frontends. Have them on multiple boxes.”

Thanks

Any update on this? I also enabled this option during the deployment but it seems it’s not working at all… ive created the required table as per the scriptcase blog but still doesnt work for me. Im using the latest updated version by the way