DeluXe Network Forums
March 22, 2010, 05:10:47 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Please do not add ads in your signature!
 
   Home   Help Search Members Login Register  
Pages: [1]
  Print  
Author Topic: Header('Location:') and setcookie  (Read 206 times)
mossg
Newbie
*

Honor: 0
Offline Offline

Canada Canada

Posts: 1


View Profile
« on: December 16, 2009, 05:57:50 am »

Alright. I have a login system (simple).

<?php
if($_POST["pass"] == "bokchoy")
{
setcookie(pass,bokchoy,time()+1800);
header("Location: members.php");
}
else
{
setcookie(pass,wrong,time()+1800);
header("Location: wrong.php");
}
?>


On the previos page, there is a form. That sends "pass" to this page. The login goes though, and NOTHING happens when i load this page. I am not redirected to members.php OR wrong.php and the cookie is not set. Please help. the code was placed in the body. the website is www.dhost.info/mossg (class website, dont laugh)
« Last Edit: December 16, 2009, 06:05:43 am by mossg » Logged
Michael
Administrator
Hero Member
*****

Honor: 11
Offline Offline

Germany Germany

Posts: 3256



View Profile WWW
« Reply #1 on: December 17, 2009, 10:46:28 pm »

there two problems with your script:

change setcookie(pass,bokchoy,time()+1800); to setcookie("pass","bokchoy",time()+1800);

and remove the empty first line of your script, as this is already sent to the browser you cannot modify the headers (which you are doing with the "Location")
Logged
Pages: [1]
  Print  
 
Jump to:  

 

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.27 seconds with 17 queries.