Jump to content

Recommended Posts

ok i am try to make a remimber me script but i am have problems with the setcookie() ans the session_start();

here is the code

<?php
session_start();
if(!session_is_registered(username)){
header('location:login.php');
}
?>


<?php
include'db.php';
$session=$_SESSION['username'];
$run=mysql_query(" SELECT * From admin WHERE login='$session'");
while($row=mysql_fetch_array($run))
{
$row['login']=$user;
$expire= time()+60*60*24*14;
setcookie("$user", "$value", $expire);//Line 17
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

and here is the ERROR

Warning: Cannot modify header information - headers already sent by (output started at /home/bob/public_html/ad/admin/cookie.php:9) in /home/bob/public_html/ad/admin/cookie.php on line 17
Link to comment
https://forums.phpfreaks.com/topic/180912-stupid-little-problem/
Share on other sites

just the databases conntion stuff

<?php
$host = "localhost"; //database location
$user = "bob_ad"; //database username
$pass = "*********"; //database password
$db_name = "bob_ad"; //database name
//database connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);

 

See the blank lines outside of the php tags?

?>


<?php

Those are sent to the browser.  So you cannot send any more header information to the browser because you have already sent content.  Remove the blank lines.  In fact, there is no reason to close and re-open the php tag, so remove them too.

See the blank lines outside of the php tags?

?>


<?php

Those are sent to the browser.  So you cannot send any more header information to the browser because you have already sent content.  Remove the blank lines.  In fact, there is no reason to close and re-open the php tag, so remove them too.

 

i took that code from the another script that the reason it there is was removed before but i will delete all the lines

 

bob

You also need to put an exit; statement right after the header() redirect to prevent the remainder of the code on the page from being executed while the browser preforms the redirect. The current code won't protect the content on the page if a hacker ignores the header() redirect.

You also need to put an exit; statement right after the header() redirect to prevent the remainder of the code on the page from being executed while the browser preforms the redirect. The current code won't protect the content on the page if a hacker ignores the header() redirect.

 

??? lol

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.