I'm trying to start a session in .htaccess using php_value session.auto_start 1
to avoid duplication of lines in php codes.
But this is not working, is it always off?
I'm trying to start a session in .htaccess using php_value session.auto_start 1
to avoid duplication of lines in php codes.
But this is not working, is it always off?
Note: In this case the author is experimenting with the free version of hostinger, which is probably limited and does not have full support (I can not say, it's a guess) and this seems to be the reason for the problem
I think the command is php_flag
and not php_value
, example:
php_flag session.auto_start 1
To test create an empty file named teste.php
in the same folder that is .htaccess
with this content:
<?php
var_dump(session_id(), $_SESSION);
It should return something like:
string(26) "jgg7lol8o97733q3vgs46tm7p5" array(0) { }
This means it's working.
If this does not work you can do the following, create a file named global.php
, add the following content in it:
<?php
if (session_id() === '') {
session_start();
}
And include this file in all required files, for example the file index.php
<?php
require_once 'global.php';
?><!DOCTYPE html>
<html>
<head>
Resto do html...