Jump to content

Weird Cookie Problem


Recommended Posts

I have a very odd cookie problem that's hard to explain so please bare with me...


The first piece of code found below is the login process, where the login is checked and the cookie is created or not, the second piece of code below is a library which is called to display the login menu and get the connection to the database.


The problem I'm having is I cant put these 2 files in the same folder. The cookie gets created if i put the process login into a directory and the library into a sub directory called inc ... then i "include("inc/library.php");" in the login process. I then point the form for the login to http://www.alcaeos.com/blog/loginProcess.php...


If I do these 2 things then the cookie is created but if I place both files in the inc folder (The code below is the example of when both files are IN the inc folder) then the cookie does not get created. the login system still works and tells the user if they successfully logged in or not, it just wont create the cookie... It's an odd problem I think. Has anybody got any ideas... Thanks






$username = $_GET['username']; 
$password = $_GET['password'];

$sql = "SELECT * FROM theUsers WHERE user = '$username' AND pass = '$password';";

$result = mysql_query($sql) or die(mysql_error());  

if ($obj = mysql_fetch_object($result)) 
echo "<A HREF='http://www.alcaeos.com/blog/test.php'>You are logged in</A>";


echo "You are NOT Logged In";




function loginScreen()

$output = <<<LOGIN

	<FORM method ="GET" action="http://www.alcaeos.com/blog/loginProcess.php">
			<td>Username: </td>
			<td><INPUT TYPE = "text" NAME = "username"></td>
			<td>Password: </td>
			<td><INPUT TYPE = "password" NAME = "password"></td>

	<INPUT TYPE="submit">


echo $output;

function connectToDatabase()	
$dbhost = 'mysql*******';
$dbuser = 'kem*******';
$dbpass = 'ya****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');

$dbname = 'ke********';




Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.