Session
Brought to you by:
jberanek
I have question. Can you explain a bit more regarding the session, because currenly, im integrating mrbs with my current web system. I wanted to use the same session when user log in the current system, to link to the mrbs so that the user doesnt have to log in again. Is it doable?
How does authentication work in your web system? Are you using a standard system such as Joomla or Wordpress? If so, you can just set $auth['type'] and $auth['session'] appropriately.
If you've got your own custom scheme then you'll probably have to write your own auth and session modules.
Im just using a normal php website. Well, the authentication method is also just simple, the user key in username and password and directly check in the database. If the password and username matches then it will go to a hompage that user will select from few options ie: helpdesk, mrbs. Because I dont really get how you throw the session inside the mrbs. Mind to explain some more?
I use cpanel as my platform.
You'll need to write your own session module implementing the following functions:
authGet()
getUserName()
print_logon_box()
logoff_user()
and it should also process the results of a login form. See session_php.inc for an example.
Means i cannot directly link? I have to do another page to get the session from the previous homepage?
No, you won't have to have another page. You just need to write some code that will enable MRBS to know whether a user is already logged in to to your website.
On your website, how do you know whether a user is already logged in if they move from one page to another?
Last edit: Campbell Morrison 2019-06-29
I created a session for the user using normal php. Here I attached the login page and where it redirect when user already logged in. Is this sufficient to explain?
Then you can pick up the username from
$_SESSION. For example, for getUserName()I suggest you model your MRBS session module on session/session_php.inc.
However, it still prompts session expired. Mind to explain more? Ive been trying to figure out, but still unable to figure it out. I already try so hard but still cannot find. I need to get it online by Friday. Mind to help me a bit more?
I can attached the sample of the first page when user select the helpdesk. How it redirect and maintain the session for your reference.
Or do we have to throw hidden value for the username and password to the login form and let it process and create its own session?
Because I found out that it cannot capture the session. Im sorry for the inconvience.
Any advise?
You are going to have to write your own auth and session modules, let's call them auth_custom.inc and session_custom.inc. In your config file you will then define both $auth['type'] and $auth['session'] as 'custom'.
The auth module is probably best based on auth_db_ext.inc and should implement authValidateUser($user, $pass), authGetUserLevel($user), authGetUserLevel($user) and authGetUserEmail($user) by querying your database to get the results.
The session module should implement authGet(), getUserName(), print_logon_box() and logoff_user() and it should also process the results of an MRBS login form, by logging on a user in your system, ie by setting the session variables, on successful login.
At the config file, do i have to change this line from db_ext to custom too?
Last edit: Campbell Morrison 2019-07-02
It depends whether you want to use these config variables in auth_custom.inc.
Or do you mind guiding me on writing the auth_custom module? Im really blur in this. Im sorry for asking you so much.
Sorry, I'm afraid I haven't got time to do more than point you in the right direction.
I try first, then I let you see what I did later. Thank you and sorry for the inconvinience
I did it! Thank you. But however, if i use admin or the department login id and password can. But if i login using user login id, it cannot capture.
Example:
Uname: itdepartment
Pword:sk12345
Able to capture the session.
But when I login
Uname: SC1855
pword: sc1855
Unable to capture the session.
Mind to explain why?
I don't know. Maybe it's to do with the case of the username. Is it being converted to lowercase before you check in the database?
Last edit: Campbell Morrison 2019-07-04
How can i know if its converted to lowercase?
You'll need to put some debugging code in your auth and session modules to find out why SC1855 isn't being recognised.