Solved

create a cookie

Posted on 2000-02-18
3
178 Views
Last Modified: 2008-03-06
I am creating a cookie?I am not using any <html> or <head> tags before it.There is only  database connection and retrieving some values from it.I am getting Error as "cookie is Set after header is passed".what is the solution?
0
Comment
Question by:padmamvs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:maxkir
ID: 2538459
check any require() or include() directives before sending a cookie in your text.
I bet that some of the included files outputs some blank characters.

I mean, if you make

include("config.inc");
SetCookie(...);

and file config.inc is like that:
<?php
//stuff
?>
[spaces]
-- end of file --
then these spaces are sent before your SetCookie command - so PHP gives an error.
0
 

Expert Comment

by:tejass
ID: 2539516
I completely agree with maxkir
0
 
LVL 1

Accepted Solution

by:
aikon earned 20 total points
ID: 2539840
Hi padmamvs,

The cookie code must be before any code you put ei php or html.

Regards.
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question