[SOLVED] Preventing someone from skipping login page
Moderator: General Moderators
-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
Preventing someone from skipping login page
How can I prevent someone from typing in the filename to by-pass the login menu? Is there away to prevent this?
Code: Select all
<?php
if (isset($_SESSION['logged'])) {
// display page
} else {
// display login page
}
?>-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
yeah u can assign any var to the SESSION global. ie:
/ $_SESSION['logged'] = true;
/ $tim = "tim";
$tim = $_SESSION['name'];
/ $_SESSION['name'] = "tim";
edit, again - more examples to help ya out
$_SESSION['name'] = $_POST['username'];
/ $_SESSION['logged'] = true;
/ $tim = "tim";
$tim = $_SESSION['name'];
/ $_SESSION['name'] = "tim";
edit, again - more examples to help ya out
$_SESSION['name'] = $_POST['username'];
Last edited by tim on Thu Jun 17, 2004 8:02 pm, edited 3 times in total.
-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
Undefined variable: _SESSION
I'm getting this when i'm trying to check if the session is true
this is just a smaple page 'm trying to get working beofre i work other apges so i can get the hang of it.
page one
<?PHP
$_SESSION['logged'] = true;
header("Location: help.php");
?>
page two
<?php
$ans = $_SESSION['logged'];
echo $ans;
if ($ans == true)
{
echo "HELLO";
}
?>
I'm getting this when i'm trying to check if the session is true
this is just a smaple page 'm trying to get working beofre i work other apges so i can get the hang of it.
page one
<?PHP
$_SESSION['logged'] = true;
header("Location: help.php");
?>
page two
<?php
$ans = $_SESSION['logged'];
echo $ans;
if ($ans == true)
{
echo "HELLO";
}
?>
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
You gotta have
at the top of every page.
Code: Select all
session_start();-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am
Here are the warns i'm getting now
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\phptesting\help.php:2) in c:\inetpub\wwwroot\phptesting\help.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\phptesting\help.php:2) in c:\inetpub\wwwroot\phptesting\help.php on line 3
my code for those pages is below
page one
<?PHP
session_start();
$_SESSION['logged'] = true;
header("Location: help.php");
?>
page two
<?php
session_start();
if (isset($_SESSION['logged'])) {
// display page
} else {
// display login page
}
?>
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\phptesting\help.php:2) in c:\inetpub\wwwroot\phptesting\help.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\phptesting\help.php:2) in c:\inetpub\wwwroot\phptesting\help.php on line 3
my code for those pages is below
page one
<?PHP
session_start();
$_SESSION['logged'] = true;
header("Location: help.php");
?>
page two
<?php
session_start();
if (isset($_SESSION['logged'])) {
// display page
} else {
// display login page
}
?>
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
-
stantheman
- Forum Commoner
- Posts: 38
- Joined: Wed May 26, 2004 8:57 am