Jump to content

Start always with localhost/index.php


ochi

Recommended Posts

hi! I want to forbide people write in the browser:

 

www.mydomain.com/wathever.php

 

The wathever.php is what I want be impossible, because in index.php I have a login/password system.

 

I tried with  $_SESSION['auth'] but, it's not possible, because it's just cleaned with "logout" bottom or closing the browser.

 

Could you help me?

 

thank you! Regards

Link to comment
Share on other sites

Hi, what I want to do is follow the links in the site, starts in index.php and continue with the links, so, if index.php have a link to second.php I can't write www.localhost/second.php, it should redirect to index.php

 

I tried, when the user login in index.php put a variable: $_SESSION['auth'] = true, and in every php file:

 


<?php
session_start();
if (!$_SESSION['auth'] == true){
	header("Location:/index.php");
}
?>

 

But it doesnt work fine, because I cant remove this variable if I would do it I wont be able to use the "go to the previous page" for example, I also tried different variables, but the problem stil appears.

 

Another thing is as I never delete it, when I close the browser and open a new one, it's still there.

 

 

Thank you! Regars

Link to comment
Share on other sites

Hi! the problem isn't how to call this, it works also with:

 

if(!isset($_SESSION['auth']))

 

the problem is: once I active this variable I had the problem with the page it allows! for example in index.php I put:

 

if (autorized){
  $_SESSION['auth']
} else {
   the page
}

 

and it have a link to: page2.php wich starts:

 

if(!isset$_SESSION['auth']){    
     header("Location:/index.php");
} else {
   the page
}

 

If I close the mozilla and I forgot put logout button I can write : http://www.localhost/page2.php and I want it are not allowed.

 

If page2.php starts:

 

if(!isset$_SESSION['auth']){    
     unset($_SESSION['auth']);
     header("Location:/index.php");
}

 

The previous problem is solved, but, now I cant refresh or use the "go to the previous page" in mozilla, because, I'll start again in index.php

 

Do you understand me?

 

thanks! regards

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.