php - How to handle different login credentials for modules in one project? -


i new php programming , think might have security issues session variables.

i working on project has 3 modules require separate login credentials. 3 modules students, teachers , administration.

after user logs in respective portals, these credentials stored session variables. let's have 2 tabs open in browser, 1 has student portal open , other has admin portal open. if student logs in first portal user id 1 shortly after admin has loged in user id 2, userid both portal appears same(userid 1). problem session variables both portals getting shared in browser.

sometimes session variables pulled previous session in new tab after closing it.(*tested using var_dump[$_session]*)

can please explain me how limit session variables each portals or provide me hints other ways of security handling in php?

ps: have logout buttons clears session variables. problem seems persist if tab closed or new portal opened in new tab.

thanks in advance.

from browser server 1 php session started (apart private browsing options, that's off topic) , "shared" among tabs. in contrast @fejese's answer suggests, can solve situation using 1 php session. problem use same session variable indicate logged in regardless of access level of logged in user.

as 3 separate modules handle authentication, create 3 different session variables indicate user logged in. e.g. when student logs in, craete $_session['auth_student_id'] , assign logged user (student) id it. when teacher logs in, create $_session['auth_teacher_id'], , forth.

then, depending on portal loaded, ignore other session variables. if in tab 1 student portal loaded, check $_session['auth_student_id'] , ignore others. if set, know portal should show protected content because user (student) has authenticated themselves. if in tab 2 teacher portal loaded same $_session['auth_teacher_id'] , ignore other 2.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -