Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

sessions

I'm trying to start a session for use on a number of pages. I get this error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/dc/keywordeditor.php:8) in /var/www/html/dc/keywordeditor.php on line 15


What am I missing??

TIA Dinesh
0
dprasad
Asked:
dprasad
  • 2
2 Solutions
 
Diablo84Commented:
session_start();

must go before ANY output which includes:

- new lines or spaces before the opening php tag (<?php)
- html tags
- php output (including echo and print).

In an ideal situation session_start(); should be placed at the very top of your file before anything else
0
 
Diablo84Commented:
Also take into consideration the factor of output from any include files you may have, php.net say it best:

QUOTE "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file."

http://us2.php.net/manual/en/function.header.php

This applies to anything that uses the http_headers, not only session_start (eg the header function and setcookie).
0
 
_Marcel_Commented:
Line 8 of keywordeditor.php would be the line that outputs the stuff.

If you can't move up the session_start(), then use an output buffer around the earlier lines.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now