Working with PHP Sessions -


I have just developed a user login system and want to create separate sessions for different users.

How do I write a code in PHP so that it starts a session and if the user name is "a", then it redirects to a different page and if the username is "B", then it Redirects to a different page.

Update:

I used it

  session_start (); Switch ($ _SESSION ['username']) {case 'a': // $ _SESSION ['username'] is redirected to 'a' // file1.php header ('location: file1.php'); Die (); break; Case 'B': // $ _SESSION ['Username'] is redirected to 'B' // file2.php header ('location: file 2.fp'); Die (); break; Default: // $ _SESSION ['Username'] is not set to a, not B, or all // redirect to default.php header ('location: default.php'); Die (); break; }  

but it does not matter if you enter any user name, it is taking me to file1.php

  session_start (); // ... if ($ _SESSION ['username'] == 'A') {header ("location: ./page_a"); } And if ($ _SESSION ['username'] == 'b') {header ("location: .page_b"); } Other {header ("location: ./otherpage"); }  

Comments