Why Ob_Start() Must Come Ahead of Session_Start() to Work in PHP

Methods ob_start and ob_flush don't work, why?

You also need to check the PHP settings

some installs default to 4096, some default to off

output_buffering = Off

output_buffering = 4096

agreed with George but do check the above settings

I need help on PHP session on login

You need to call start_session() before you try to read from $_SESSION

<?php
ob_start();
session_start();
if (isset($_SESSION['admin'])) {
header('Location: admin.php');

As MarcB points out, you also need to do this before setting the session variable in index.php.

php - ob_start / fputs suddenly doesn't work anymore, is there anything that can stop it?

I'm not sure why fputs isn't working, it is probably to do with your servers folder permissions (usually 0755 or 0775 is safe), could also add a condition to check is_writable to eliminate that possibility. Have you tried using file_get_contents and file_put_contents.

define('FILE_PATH', 'path/to/file/file.log'); 
function log_this($command, $array = null) {
//check if we can get to the file
if(file_exists(FILE_PATH)){
$current = file_get_contents(FILE_PATH);
$current .= $command;
if(!is_null($array)){
ob_start();print_r($array);$output = ob_get_clean();
$current .= $output;
}
file_put_contents(FILE_PATH, $current);
}
}

Sessions and php redirect doesn't work

Mystery solved here:
Byte Order Mark

Sample Image

Best answer you will find:

https://stackoverflow.com/a/8028987/424004



Related Topics



Leave a reply



Submit