Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

session_start() error

Featured Replies

Hey,

 

Im getting the below error, how can i get around this?

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /#####/#####/#####/functions.php:3) in /#####/#####/#####/functions.php on line 11

 

Thanks,

Basically means exactly what it says... that headers have already been, so you cant send any more. The error is stating that line three of functions.php has already sent the headers to the browser. It could be whitespace in an include file or you're already outputting data to the browser.

This means you've already written some body content to the response before you called session_start(). As it routinely affects the headers (which are submitted before the body), it should appear near the beginning of your script.

 

Even if you haven't written content explicitly before the session_start() call, look out for white space outside <?php ... ?> tags etc., as the whitespace can be written to the body too.

 

I tend to structure scripts as:

 

<?php

// includes and requires which don't output anything

session_start();

// rest of script

?>

Does that solve it for you?

Edited by Connetu_C

This means you've already written some body content to the response before you called session_start(). As it routinely affects the headers (which are submitted before the body), it should appear near the beginning of your script.

 

Even if you haven't written content explicitly before the session_start() call, look out for white space outside <?php ... ?> tags etc., as the whitespace can be written to the body too.

 

I tend to structure scripts as:

 

<?php

// includes and requires which don't output anything

session_start();

// rest of script

?>

Does that solve it for you?

 

Actually this

 

<?php

// includes and requires which don't output anything

session_start();

// rest of script

?>

 

Would cause errors cause u have spaces before the session start which is also considered output.

 

EDIT: actually i should stress this would just be the case if theres a space before <?php but useful info just the same

Edited by webdesigner93

Yep, working with session stuff at the moment and I try to make sure that session_start(); is the first line of all my PHP session scripts.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.