Jump to content

creating and checking session problems


blink359

Recommended Posts

Hi there i have made a  mistake setting or checking my sessions and was not sure what it is because i cant reach my locked content

 

Creating:

session_start();
if ($role="valiant") {
$_SESSION["username"] =="valiant";
header("location: 1/index.php");
}elseif($role="vulcan") {
$_SESSION["username"] =="vulcan";
header("location: 2/index.php");
}else{
echo "Wrong Username or Password";
}

Checking:

<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username']) || $_SESSION['username'] != "valiant") {
header("location:../index.php");
}

?>

//OR

<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username']) || $_SESSION['username'] != "vulcan") {
header("location:../index.php");
}

?>

Any help will be great

 

Thanks,

 

 

Blink359

Link to comment
https://forums.phpfreaks.com/topic/219439-creating-and-checking-session-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.