am getting Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent while running the following code. please help to fix it.. thanks.

<html>
<!-- centermain.php is a frame, user redirected to frame if tried to access from url-->
<SCRIPT LANGUAGE='javascript'>try { if (top == self) {top.location.href='centermain.php'; } } catch(er) { } </SCRIPT>
</html>
<?php
session_start();// initialize session
//code
?>

Recommended Answers

All 5 Replies

TRY THIS

<?php session_start();  ?>
<?php ob_start(); ?>
<html>
<!-- centermain.php is a frame, user redirected to frame if tried to access from url-->
<SCRIPT LANGUAGE='javascript'>try { if (top == self) {top.location.href='centermain.php'; } } catch(er) { } </SCRIPT>
</html>


<?php ob_end_flush();?>
Member Avatar for P0lT10n

You code is not working because session_start(); ALWAYS MUST BE FIRST IN THE FILE...

it works.. thanks amr :)

you welcome , plz mark this thread as solved

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\emohonv2\module-srksmka.php:293) in C:\xampp\htdocs\emohonv2\auth.php on line 3

Code:

<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION) || (trim($_SESSION)=='')) {
header("location: access-denied.php");
exit();
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.