Working with PHP Sessions

wangbao

New Member
I just developed a user login system and want to create different sessions for different users.How do I write a code in PHP so that it starts a session and if the username entered is "a", it redirects to a different page and if the username is "b", it redirects to a different page.Update:I used this\[code\]session_start();switch ($_SESSION['username']) { case 'a': // $_SESSION['username'] is 'a' // redirect to file1.php header('Location: file1.php'); die(); break; case 'b': // $_SESSION['username'] is 'b' // redirect to file2.php header('Location: file2.php'); die(); break; default: // $_SESSION['username'] is neither a, nor b, or is not set at all // redirect to default.php header('Location: default.php'); die(); break;}\[/code\]but no matter what username I enter, it is taking me to file1.php
 
Back
Top