php - Mapping sessions to users -


When I login to a new session, then it is generated. How can I know later in which session was logged?

I am getting the value of the session, but how will I know which session is for the user and redirect it to that page?

You do not want to create a new session when you are entering the user.

login.php

  and  

(); If ($ _POST ['user'] == 'John' & $ _POST ['PWD'] == 'password') {$ _SESSION ['login'] = true; $ _SESSION ['first name'] = 'John'; }? & Gt;

admin.php

  & lt ;? Php session_start (); If (! Isset ($ _ session ['login']) || $ _ session ['login']) {header ('location: login.php'); Go out(); } 'Hello' echo $ _SESSION ['first name'] '!'; ? & Gt;  
  • A user visits admin.php
  • session_start () creates a new session for all data ($ _SESSION ) A new cookie client-side is stored with the ID of the session stored on the server.
  • The user is redirected to login.php so that no $ _ session ['login'] key is set to true
  • Session_start () revive session with cookie sent by browser
  • User submits a form and authentication $ _ session Inside the array, we note this.
  • User goes back to admin php and can now access the page.

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -