# Notice: Undefined index with a setcookie

**URL:** <https://forum.kirupa.com/t/notice-undefined-index-with-a-setcookie/167631>\
**Category:** programming\
**Created:** [October 30, 2005, 11:12am UTC](https://forum.kirupa.com/t/notice-undefined-index-with-a-setcookie/167631 "2005-10-30T11:12:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sWo0p](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sWo0p](https://forum.kirupa.com/u/sWo0p)\
**Post date:** [October 30, 2005, 11:12am UTC](https://forum.kirupa.com/t/notice-undefined-index-with-a-setcookie/167631/1 "2005-10-30T11:12:45Z")

</div>

ej guys… strange thing… i made myself a login script with a setcookie… but somehow there is a strange error…

i test this script on my own php server it works fine… but if i upload it to the webserver its suppose to go on, there is an error… and i just cant seem to find what it is… ???

**index.php:**

```php

<?

include "login_config.php";

if(isset($_POST)){
	foreach($_POST as $key => $val){
		$$key = $val;
	}
}

if(isset($submit) && $submit != ""){

if ($name == $corr_name && $pass == $corr_pass ) {  

setcookie('login', $value, time()+900); //* 15min (900sec) *//
header("Location: $pagina");

} else {

	echo "Eerst inloggen A.U.B of voer de goede gegevens in....";
	exit;
 } 
}

?>

<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<center><font class="atentie_tekst">(Administrators hebben allen toegang hier..)</font></center>
<table border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
	<td>Login:<br><INPUT TYPE="name" SIZE="15" NAME="name"><br></td>
	<td>Paswoord:<BR><INPUT NAME="pass" TYPE="password" SIZE="15"><br></td>
</tr>
<tr>
<td><INPUT TYPE="submit" NAME="submit" VALUE="Login">&nbsp;<input type="reset" name="submit" value="Herstel"></td></td>
</tr>
</table>
</form>

```

**login\_config.php:**

```php

<?

$corr_name = "test";  
$corr_pass = "test";  

$pagina = "inhoud_pagina.php";  

$value = 'true';

?>

```

**inhoud\_pagina.php**

```php

<?php  

include "login_config.php"; 
  
if ($_COOKIE['login'] == true){  

?>

hallo

<?

} else {  

echo "<script LANGUAGE='javascript' TYPE='text/javascript'>window.location='$pagina'</script>";  

} 

?> 

```

**Error mssg:**

Notice: Undefined index: login in …inhoud\_pagina.php on line 5 (keep kliking (looping))…

kan anyone help me… ???
