php - Is it good to wipe $_SESSION before using it? -


I'm still new to sessions wipe out $ _ session Is before using it?

Example:

  $ _ session = array (); $ _SESSION ['id'] = 1; $ _SESSION ['name'] = 'any';   

I am telling you people's opinions.
Because I do not have many experiences in the session .

In my strange logic, maybe I could write from logout to administrator session and login > Member Session

Therefore, any $ _ session / value from admin will still be in the $ _ session array


Extra:
1. I Admin user and logout from admin page was not
2. Now I go from admin page to member login page

What should I do here?
kick admin admin page because he is not a member?

no In fact, very bad and your example code will make your sessions unusable.

When you call session_start () you are given a blank $ _ session / > or you $ _ Sessions can retrieve data saved on For more information about sessions, check the PHP docs:


About logging in and out: Your logout process Any session data that is destroyed by the user recognizes (perhaps their ID) is usually done by using unset , i.e. unset ($ _ session ['user_id']) Is .

I can not imagine any other way to log out a user, if you have provided more information, then I can give you a better answer about it.


It appears about your excess that your authentication system can use some work when you are already logged in, then you should not be able to reach a login page. (Even as an administrator, because it is the second user with more privileges, right?). If you have manually typed in the login url, you will have to redirect the homepage to it.

Good writing on this topic, I should do some research! Thanks @ Hamza

And here is my super basic phony code authentication process:

  Does the current page need authentication Yes: What user Login? Yes: Are the users the right private sector to see? Yes: credentials! Show page number: Print a message that says something like, "You are in the wrong place" No: No redirects to login: Page    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -