Jump to content

Recommended Posts

Hi I have another problem I think.

I get these error messages:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\websites\bookmark.php:1) in C:\websites\bookmark.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\websites\bookmark.php:1) in C:\websites\bookmark.php on line 1

 

Now I have looked around and found that you need to put session_start(); before any headers etc so my session_start() is located here:

 

<?php
function display_header($title)
{
[b]session_start();[/b]
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
  <html>
    <head>
      <title><?php echo $title; ?></title>
    </head>
  <body>

 

This gets called through bookmark.php with require_once();

 

There is no header information going before this so I dont understand. Also it worked on my other computer before. Its really p***ing me off.

Link to comment
https://forums.phpfreaks.com/topic/146777-solved-session_start-problem/
Share on other sites

thank you very much for the reply, but I tried this and didnt work. I have also placed it in the book mark before anything else. Also I have checked every included php page that there are no spaces before the <?php tag and end ?> tag.

It is exactly as I had it on my other computer before that got hacked and detroyed.

i use notepad for all code anyway. What is BOM?

edit: I know that it is producing errors, but would it still not register sessions? because in my other computer i didnt have error reporting activated so I might have not noticed the warnings. It still registered sessions on that... Is there a quick way to check sessions are stored?

Ok i got rid of the first error message.

 

i have this error message:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\websites\register.php:1) in C:\websites\output.php on line 4

 

here is the start of the register file:

<?php
  require_once('bookmark.php');

  $show = true;

  if(filled_out($_POST['register']))
  {
    $first_name = $_POST['first_name'];
    $surname = $_POST['surname'];
    $user = $_POST['user'];
    $email1 = $_POST['email1'];
    $email2 = $_POST['email2'];
    $passwd1 = $_POST['passwd1'];
    $passwd2 = $_POST['passwd2'];

 

here is the start of the bookmark.php file:

 

<?php
function display_header($title)
{
session_start();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
  <html>
    <head>
      <title><?php echo $title; ?></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
  <body>

 

Its all part of the same thing. Basically I have 1 php page tht includes a list of my functions.  This is bookmark.php.

Now in bookmark.php I have session_start(); in the function that calls the html header.

 

Also to get rid of that first cookie error I changed something in the php ini file. I manually installed this php so it could be a problem to my ini file. Do you have to do anything with the ini file for sessions when you manually set it up?

Thanks for the help.

This is friggin wierd...

 

I have just tried to test register. I got registered and now it appears the session is stored. Yet I still get this error message.

Also I cant logout because the session has not been initialised?

 

here are the errors when I try to logout:

 

Notice: Undefined variable: _SESSION in C:\websites\logout.php on line 4

Notice: Undefined variable: _SESSION in C:\websites\logout.php on line 5

Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\websites\logout.php on line 6

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\websites\logout.php:1) in C:\websites\output.php on line 4

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.