Jump to content

Cookies not being set


guymclaren

Recommended Posts

The code below is the only part of my script failing and I have no clue why. I even tried setting the TestCookie for 352 days. What boggles my mind is that this code used to work and is now failing. Has something changed?

 

$value = "wtf";

setcookie("TestCookie",$value, time()+3600*24);

 

setcookie("user", $name1, time()+14400);

setcookie("userid", $uid1, time()+14400);

setcookie("coid", $coid1, time()+14400);

setcookie("login", "yes", time()+14400);

setcookie("status", $status1, time()+14400);

Link to comment
Share on other sites

Here is the full code in context

 

<?php

 

include ("../navigation/header.php");

$ident = "0";

 

$basket = $_REQUEST["id"];

$name = $_REQUEST["uname"];

$pass1 = $_REQUEST["pass1"];

 

include ("../navigation/constants.php");

?>

<div id="contenti">

<div id="iwrap1">

 

<div class="post-title">

<h2> Catalogue - Log In</h2>

</div>

<div id="post-entry">

<?

//Check if form has been filled in

If ($name != NULL){

If ($pass != NULL) {

//check database

$sqlq="SELECT * FROM Clcontacts INNER JOIN Clients ON Clcontacts.Company=Clients.id WHERE Clcontacts.email = '".$name."' AND Clcontacts.password = '".$pass1."'";

$objRS = mysql_query($sqlq);

$rows = mysql_num_rows($objRS);

 

          if ($rows == 0) {

echo "<h2>Log in failed</h2>The username or password is incorrect, please try again";

?>

<h2>Log In</h2>

<form action="login.php" method="GET">

<table>

<tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr>

<tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr>

<tr><td></td><td><input type="submit" value="Submit" /></td></tr></table>

</form>

<? }

else {

$email = mysql_result($objRS, 0,"Clcontacts.email");

$name1 = mysql_result($objRS, 0,"Clcontacts.name");

$uid1 = mysql_result($objRS, 0,"Clcontacts.id");

$coid1 = mysql_result($objRS, 0,"Clients.id");

$status1 = mysql_result($objRS, 0,"Clcontacts.status");

 

echo $email." ".$uid1." ".$coid1." ".$status1."<br />";

$value = "myfuckingtime";

 

setcookie("TestCookie",$value, time()+3600*24*352);

 

setcookie("user", $name1, time()+14400);

setcookie("userid", $uid1, time()+14400);

setcookie("coid", $coid1, time()+14400);

setcookie("login", "yes", time()+14400);

setcookie("status", $status1, time()+14400);

 

echo  "Welcome ".$name1.", You have succesfully logged in.<br /><br />";

 

$loggedin = $_COOKIE["login"];

echo $loggedin;

 

}

} }

else {

?>

<h2>Log In</h2>

<form action="login.php" method="GET">

<table>

<tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr>

<tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr>

<tr><td></td><td><input type="submit" value="Submit" /></td></tr></table>

</form>

<? } ?>

 

</div>

<div class="post-info"></div>

</div>

Link to comment
Share on other sites

Archived

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.