/    Sign up×
Community /Pin to ProfileBookmark

Cookie not working

Hi,
i’m making a login-page for my website [url]www.ezemaal.tk[/url]
And i want to use a cookie so when someone comes back to my site, he/she is automatically logged in. The problem is that i can’t make the cookie work.
In Internet Explorer, it only works when i set my cookie settings to “accept all cookies”, instead of the default cookie settings. In Netscape it works perfectly.
But i want the cookie to work in Internet Explorer with default settings.
My domain [url]www.ezemaal.tk[/url] forwards to [url]http://users.skynet.be/yannickdelvaux/ezemaal/[/url]
But all my php files are stored on my computer (including all the login files) on [url]http://yannickdelvaux.mine.nu/ezemaal[/url]
I’ve tried filling every possible domain name in the domain section of the cookie, but nothing works.

This is the code of the 3 files that i made for the login:

login.php (this is where the user can fill in his username and password )

[code=php]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Untitled Document</title>
<SCRIPT LANGUAGE=”JavaScript” SRC=”above.js” TYPE=”text/javascript”></SCRIPT>
<link rel=”stylesheet” type=”text/css” href=”http://users.skynet.be/yannickdelvaux/ezemaal/stijl1.css” />
<!embed src=”1.mp3″ hidden=”true” autostart=”true” nosave=”true” width=145 height=55>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<style type=”text/css”>
<!–
body {
margin-right: 0px;
margin-top: 4px;
}
–>
</style></head>

<body bgcolor=”#000000″ onload=”pageChange()”>
<table height=”83px” width=”100%” border=”0″>
<tr>
<td width=”78%”>&nbsp;</td>
<td width=”22%”>
<p align=”center” class=”kleiner”>
<form method=”post” action=”inloggenbezig.php”>
<table width=”100%” border=”0″>
<tr>
<td width=”50%” valign=”top”><p align=”left” class=”kleiner”>Gebruiker:<br><input maxlength=”22″ type=”text” name=”gebruikersnaam”></p></td>
</tr>
</table>
<table width=”100%” border=”0″>
<tr>
<td width=”50%” valign=”top”><p align=”left” class=”kleiner”>Paswoord:<br><input maxlength=”22″type=”password” name=”paswoord”></p></td>
</tr>
</table>
<table width=”100%” border=”0″>
<tr>
<td width=”50%” valign=”top”><input type=”submit” name=”submit” value=”Log in…”></td>
</tr>
</table>
</form>
</p></td>
</tr>
</table>
</body>
</html>
[/code]

inloggenbezig.php (this is where the filled in username and password is compared to the one in the mysql database and where the cookie is created)

[code=php]
<?php if(empty($_POST[‘gebruikersnaam’]) || empty($_POST[‘paswoord’]))
{ ?>
<p class=”kleiner”>Vul alles in. <a href=”http://yannickdelvaux.mine.nu/ezemaal/login.php”>ga terug</a></p>
<?php exit;
}
else
{

<?php
$gebruikersnaam=$_POST[‘gebruikersnaam’];
$paswoord=($_POST[‘paswoord’]);
$db=mysql_connect(“localhost”,”beheerder”,”wachtwoord”);
mysql_select_db(“dbEzemaal”,$db);
$result=mysql_query(“SELECT * FROM tblUsers WHERE username= “$gebruikersnaam” AND paswoord= “$paswoord””);
if ($myrow = mysql_fetch_row($result)) {
//————————————————————
//$str = $username.”|”.$password;
//$up = serialize($str);
//setcookie(“ezemaalkoekje”, $up, time()+(1000*86400));
//————————————————————
setcookie(“ezemaalkoekje”,$gebruikersnaam.”-“.$paswoord,time()+(1000*86400),”/”,”users.skynet.be”,1);
header(“Location: [url]http://yannickdelvaux.mine.nu/ezemaal/ingelogd.php[/url]”);
//printf(“%s”,mysql_result($result,’0′,”username”));
//printf(” – %s”,mysql_result($result,’0′,”paswoord”));

//printf(“U bent succesvol ingelogd !!!!!!!!!!!!!!!!”);
//print($ezemaalkoekje);
//}
else {
$url=”http://yannickdelvaux.mine.nu/ezemaal/login.php”;
printf(“<p>Het wachtwoord is niet juist of de gebruikersnaam bestaat niet. Gelieve opnieuw te proberen.<br><br><a href=$url>Klik hier<a> om terug te keren naar het inlog-scherm.</p>”);
}
?>
[/code]

ingelogd.php (this should show the login as it is stored in the cookie)

[code=php]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Untitled Document</title>
<SCRIPT LANGUAGE=”JavaScript” SRC=”above.js” TYPE=”text/javascript”></SCRIPT>
<link rel=”stylesheet” type=”text/css” href=”http://users.skynet.be/yannickdelvaux/ezemaal/stijl1.css” />
<!embed src=”1.mp3″ hidden=”true” autostart=”true” nosave=”true” width=145 height=55>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<style type=”text/css”>
<!–
body {
margin-right: 0px;
margin-top: 5px;
}
–>
</style></head>

<body bgcolor=”#000000″ onload=”pageChange()”>
<table height=”83px” width=”100%” border=”0″>
<tr>
<td width=”78%”>&nbsp;</td>
<td width=”22%”>
<p align=”center” class=”kleiner”>
<?php
printf(“Ingelogd als:</p>”);
//$str = $_COOKIE[“ezemaalkoekje”];
//$up = unserialize($str);
//echo $up;
$data = $_COOKIE[“ezemaalkoekje”];
$array = explode(“-“, $data);
echo $array[0];
//Verbinding maken met de database en het aantal bezoeken eerst updaten, daarna weergeven.
//$db=mysql_connect(“localhost”,”beheerder”,”wachtwoord”);
//mysql_select_db(“dbEzemaal”,$db);
//$sql=”SELECT * FROM tblUsers WHERE “;
//$result=mysql_query($sql);

//printf(“<p align=”center” class=”kleiner”><a href=”http://yannickdelvaux.mine.nu/ezemaal/login.php”>Log in</a>”);
//printf(” – “);
//printf(“<a href=”http://yannickdelvaux.mine.nu/ezemaal/registreer.php” target=”rechts”>Registreer</a>”);
?>
</p></td>
</tr>
</table>
</body>
</html>
[/code]

Can anyone help me please ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aoeguyJun 17.2004 — All I can think of is that you set the cookie domain to where you have your PHP files.
Copy linkTweet thisAlerts:
@YannickauthorJun 17.2004 — Sorry, doesn't work, i've tried

yannickdelvaux.mine.nu

yannickdelvaux.mine.nu/

.mine.nu

.mine.nu/

http://yannickdelvaux.mine.nu

http://yannickdelvaux.mine.nu/

http://yannickdelvaux.mine.nu/ezemaal/


Nothing works...
Copy linkTweet thisAlerts:
@YannickauthorJun 19.2004 — Anyone ?
×

Success!

Help @Yannick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...