Re: Help!? Auth and Redirect!!!
| From: | Michael Bretterklieber | Date: | Thu, 13 Feb 2003 16:08:40 +0000 |
| Subject: | Re: Help!? Auth and Redirect!!! | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13234@lists.php.net to get a copy of this message | ||
Hi,
what kind of server software you are using?
There is a bug in IIS when "setcookie" and "location" headers are sendet at the same time, then the cookie is lost :-(
maybe that's your problem.
bye,
Jochen Schneider schrieb:
Hi! I'm using Pear's Auth classes and I've made some good experiences with it, until now. Trying to combine a Auth-Session with an Header-Redirect, I'm loosing the session during the Redirection and the called site is asking me for authorization again. I did some searches and found in the manual(php.net) the function "session_write_close()" to be called before doing a Forward. But I havent succeeded anyways. So help me please, cause I dont know how to solve this and I'm getting mad after days of trying and testing... ;-) Here's some code pieces, for testing! BTW, It seems to be a problem of CGI-Installations.... Many thx and best regards Jochen Schneider First site (1.php): <?php require_once('./includes/application_top.php'); require_once(authenticate.php); $sessarray = $myauth->getAuthData(sessarray); echo "sessarray: ".$sessarray['mstufid']; $sessarray2 = array("a"=>"Orange", "b"=>"Banane", "c"=>"Apfel"); $sessarray = array_merge($sessarray, $sessarray2); $myauth->setAuthData($sessarray); //for testing //session_write_close(); //calls after 5 sec. the page 2.php //Ausgabe an den Browser $fwdTime = "5"; $fwdURL = "2.php"; echo " <html xmlns=\"http://www.w3.org/TR/xhtml1/\"> <head> <title>test</title> <meta http-equiv=\"refresh\" content=\"$fwdTime; URL=$fwdURL\"> </head> <body> </body> </html> "; echo "<a href='2.php'>2.php</a>"; ?> The called site (2.php): <?php require_once('./includes/application_top.php'); require_once(authenticate.php); $sessarray = $myauth->getAuthData(sessarray); echo "sessarray: ".$sessarray['mstufid']; ?> The login.. (authenticate.php): Attention, I've did some changes before posting. This should only show the auth-mechanism in common... <?php require_once('./includes/application_top.php'); require_once('Auth/Auth.php'); require_once('DB.php'); require_once(dbcon.php); //data for DB-Connection as dsn // define login form function function myloginform($username) {-- ------------------------------- ---------------------------------- Michael Bretterklieber - Michael.Bretterklieber@jawa.at JAWA Management Software GmbH - http://www.jawa.at Liebenauer Hauptstr. 200 -------------- privat ------------ A-8041 GRAZ GSM: ++43-(0)676-84 03 15 712 Tel: ++43-(0)316-403274-12 E-mail: michael@bretterklieber.com Fax: ++43-(0)316-403274-10 http://www.bretterklieber.com ------------------------------- ---------------------------------- "...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972global $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>"; exit();} // create auth object $myauth = new Auth( "DB", $AuthParams, 'myloginform', true); // start auth session $myauth->start(); // This also calls session_start() $username=$myauth->getUsername(); if (!$myauth->getAuth()) {myloginform();} ?>