I am developing my own application which requires user login. All users and passwords (encrypted) are stored in a database. When a user tries to login, then it search in the database the username and password. If all is ok, then I store username
in $_SESSION["username"]
, user role
(admin, author etc) in $_SESSION["role"]
and user website
in $_SESSION["website"]
(I need website to be stored because the application is like "multisite" - my applicaton is hosted on client hosting but the administration is on my server).
I read this Can a user alter the value of $_SESSION in PHP? and I don't understand. Is this method secure (of storing data and if user is logged in) in a $_SESSION
?
Can the user change the session content? (for example, if user is logged in and $_SESSION["website"]
is "example.com", can the user change the session $_SESSION["website"]
to "example.org" to ruin another website? If yes, how to avoid or what's the secure alternative of session?).
And please tell me what is session hijacking and how can this affect my site and also, how to make session_id dinamically to change?
Thank you so much!