Re: Newbie question...login system



On Aug 31, 11:23 am, stacey <monkeym...@xxxxxxxxx> wrote:
Hi all,

I am trying to create a login system for my site. I've got everything
working properly so far, but I would like to make it a bit cleaner.

Currently, on each page that requires the user to be logged in, I am
checking the session first and redirecting them to the login page if
they are not logged in...else, I display the page contents.

Is there a way that I can, somehow, create some sort of function that
will check a 'config' file to see if the page requires the user to be
logged in? For instance, I'd like to be able to put one call in my
header file that checks to see if the current url requires a login.
What I'm trying to avoid, is having to put the login check in each
specific page.

Also, I would like to save the referring url so I can redirect them
back to where they were trying to go in the first place.

Hope this makes sense...

Thanks in advance for any suggestions,
Stacey

Stacey,

I assume your problem is that you have a site template, or something
of the sort, that precludes you from either including your check at
the top or not. Something like I go to page1.php and at the top of
page1.php, you have <?php require_once "head.php"; ?>, where all your
autentication/authorization goes on?

if this is true...why don't you set a variable before the include.

<?php
//page1.php

$requires_auth = true;

.....
?>

<?php
//head.php

if ($requires_auth) {

.



Relevant Pages

  • Newbie question...login system
    ... I am trying to create a login system for my site. ... checking the session first and redirecting them to the login page if ... header file that checks to see if the current url requires a login. ... I would like to save the referring url so I can redirect them ...
    (comp.lang.php)
  • Re: Newbie question...login system
    ... checking the session first and redirecting them to the login page if ... header file that checks to see if the current url requires a login. ...
    (comp.lang.php)
  • ~~~~~~~~~~~~~~ LOGIN PHP ~~~~~~~~~~~~~~
    ... adding login php script on website ... complete login password system php mysql ... flash php login script ...
    (rec.audio.tech)
  • Re: PHP - D3 subroutine calls?
    ... MVWWW does the login once and then makes the connection available for ... don't think any of the MV vendors have adequately minimized the pain ... your PHP call. ...
    (comp.databases.pick)
  • Re: To allow access only from the designated site.
    ... I want to allow access to it only from site "B" login user. ... what capabilities do both servers have, do they have php, does only ... one, which one, does one/both have a database, session support? ... and to a script on siteB, and uses RSA for the form, with B's public ...
    (comp.lang.php)