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
Best answer you will find:
https://stackoverflow.com/a/8028987/424004
Related Topics
Interview Question: How to Have an Echo Before Header
Codeigniter Activerecord: Join Backticking
Set JavaScript Variable from PHP
Tcpdf and Insert an Image Base64 Encoded
Can Mongodb and Its Drivers Preserve the Ordering of Document Elements
Sharing PHP Session ($_Session) Across Multiple Domain
How to Send a File via Axios to Laravel
Is Auto-Initialization of Multi-Dimensional Hash Array Possible in Ruby, as It Is in PHP
Mysqli Query to Loop Through Array and Update Multiple Rows
How to Format a PHP Include() Absolute (Rather Than Relative) Path
How to Add Rel="Nofollow" to Links with Preg_Replace()
Different Recipients Based on Product Category in Woocommerce Email Notification
Add Custom Columns to Admin Products List in Woocommerce 3
How to Replace Some Characters with Asterisks
Why Is Turning Magic_Quotes_Gpc on Considered a Bad Practice