0

Hi,

im having a mental breakdown,
iv created a script where a user will type a password into a box and if it matches the one in the config file then it creates a session.

on all of my pages i have the following code.

<? 
session_start();
if(!session_is_registered(admin)){
header("location:login.php");
}
ini_set('display_errors','Off');
?>

but the problem im having is if i host the script somewhere else and go directly to the index.php page it doesnt ask for the password.

it should in theory redirect me to login.php

can anyon help

6
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by SKANK!!!!!
0

if the name of the session you are initiating on login is admin then you need to put it in quotes.

in your code admin becomes a global constant and since you have turned errors off, you are not redirected to the login page.

use this -

if(!session_is_registered('admin'))) // NOTE THE QUOTES

Edited by nileshgr: n/a

0

i should have added,

this only happens when i log in on one site and then try to go into a differnt site using my script.

i think i need to add somesecurity to the sesson

0

i should have added,

this only happens when i log in on one site and then try to go into a differnt site using my script.

i think i need to add somesecurity to the sesson

Didn't get you :icon_question:

0

session register or whatever doesnt work anymore.
i guess u have to set a variable to check if there is a session already started.
if the variable is empty akak $_SESSION[variablename] == ""
then there wasnt a session. make sure u set the variable to equal somethin when the session starts tho

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.