Re: Problems with Auth

From: Date: Fri, 16 Aug 2002 10:19:08 +0000
Subject: Re: Problems with Auth
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2130@lists.php.net to get a copy of this message
You will need to create the auth object on each page. If you create one include file that gets included on each page that will take care of Auth for all your pages. Example for include file <?php require_once 'Auth/Auth.php'; // set options $options = array( 'dsn' => 'mysql://test:test@localhost/test', 'table' => 'users', 'usernamecol' => 'username', 'passwordcol' => 'password' ); // define login form function function myloginform( $username ) { global $PHP_SELF; echo "<form method=\"post\" action=\"" . $PHP_SELF . "\"><br>"; echo "<input type=\"text\" name=\"username\"><br>"; echo "<input type=\"password\" name=\"password\"><br>"; echo "<input type=\"submit\">"; echo "</form>"; } // create auth object $myauth = new Auth( "DB", $options, 'myloginform', true); // start auth session $myauth->start(); // This also calls session_start() ?> Each file will now have $myauth object created providing you include the file at the start of each file. hope this helps alan

« previous php.pear.general (#2130) next »