RE: problem with include()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How did you go to the page that included the login page, if you included it
in the tiny_edit.php (which is the routine that sets the cookie in the
browser, you need to cause the browser to send it back to you by doing a
redirect;

Header("Location: tiny_edit.php");
Exit;

When tiny_edit is entered the second time it should be able to retrieve the
cookie. (this is basically what you are doing manually by refreshing the
browser).

HTH,

Warren Vail

-----Original Message-----
From: Jason Davis [mailto:mohadib@xxxxxxxxxxxxxx] 
Sent: Monday, November 01, 2004 2:34 PM
To: PHP General List
Subject:  problem with include()


Hello,
 I have a login page .. the user types in user and pass .... then the form
gets posted to tiny_edit.php 

tiny_edit.php checks user and pass then sets a cookie if auth is successful.
Then the original login page is included. The login page has logic at the
top to check for the auth cookie ... if there, it sends user to home page
.. if not it displays the login screen. This works mostly except ... when
the user auths ... the cookie gets set ... then the login page is included
.. the login page does not see the auth cookie until the user refreshes
their browser ... why is this happening?

thanks,
jd


login page ....

<?php
$bt = new AuthTool();
if($username = $bt->checkAuth()){
	//send to homepage
	print "you are already logged on $username";
}
?>

<html>
<head>
<title>
Tiny Edit Login
</title>
<link rel="stylesheet" type="text/css" href="inc/tiny_edit.css" /> </head>
<body> <form action="<?php  echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="240" cellspacing="0" border="0">
	<tr>
		<td width="100%" class="white" align="center">
			<b>Tiny Edit Login</b>
		</td>
	</tr>
</table>
<table width="240" cellspacing="0" border="0">
	<tr>
		<td class="grey" width="120" align="center">User:</td><td
class="grey" width="100"><input type="text" name="user"></td>
	</tr>
	<tr>
		<td class="grey" width="120" align="center">Pass:</td><td
class="grey" width="100"><input type="password" name="pass"></td>
	</tr>
</table>
<table width="240" cellspacing="0" border="0">
	<tr>
		<td width="100%" class="white" align="right">
			<input type="submit" value="Login"
class="submitstyle">
		</td>
	</tr>
</table>
<form>
</body>
</html>



tiny_edit.php
if(!$_GET['instance'] && !$_POST['instance']){
	$at = new AuthTool();
	if($_POST['user'] && $_POST['pass']){
		$at->auth($_POST['user'],$_POST['pass']); //this sets cookie
if user and pass are correct
	}
	include "inc/tiny_edit_login.inc.php"; 
}



thanks,
jd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux