|
|
Posted by clashers5@gmail.com on 07/18/06 03:24
I've always done somthing like this:
At the begining of your secure scripts
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Start the sesion
session_start();
// Check for login
if(!isset($_SESSION["IDUser"])){
$page = urlencode($_SERVER["REQUEST_URI"]);
exit("<script>window.location.href='login.php?page=$page</script>");
}
// Secured code goes here
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
On your login.php page
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Code used to authenticate
// On authentication, go to passed page
exit("<script>window.location.href='".$_GET["post"]."'</script>");
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HTH
Sheldon Glickler wrote:
> Look into header("Location: foo.php");
>
> Go to the login page if not set. Upon success, go to this page.
>
> Shelly
>
>
> "FP" <ad@pottnerconsulting.ca> wrote in message
> news:1153161943.943170.185580@h48g2000cwc.googlegroups.com...
> >I want to put some code at the top of my pages which will prompt the
> > user for a name & password if the session variable IDUser is not set.
> >
> > How do I get the browser to display the login / password dialog and how
> > do I access the data the user entered.
> >
> > Can I put the code that gets the login / password in a page of it's own
> > and have the browser call that page when the IDUser isn't set, and if
> > so how do I do it eg.
> > <?
> > session_start();
> > If($_SESSION['IDUser']==''){
> > //how do I tell it to do the authentication page
> > }else{
> > //rest of my code
> > } ?>
> >
> >
> > Once the user entered a login / password and I set the IDUser on the
> > authentication page, how do I tell it to resume loading the original
> > page (the one that had the above mentioned code on it)?
> >
Navigation:
[Reply to this message]
|