I am making a page with a login user database using Heroku and SQL. I am having trouble translating this from PHP and MYSQL. As part of the transition, I keep getting this error on top of every page in my website, but I can't for the life of me figure out why or how to get rid of it:
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /app/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php on line 56
I tried reading this but didn't get anywhere: ErrorException: Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /../../
Here is the login page section of my page:
$app->post('/login/', function() use($app) {
// configuration
//require("../includes/config.php");
$usernameExists = false;
$emailExists = false ;
$username = $app['request']->get('username');
$password = $app['request']->get('password');
$st = $app['pdo']->prepare("SELECT * FROM users where username = ?") ;
$st -> execute(array($username));
$userinfo = array() ;
while ($row = $st->fetch(PDO::FETCH_ASSOC)) {
$app['monolog']->addDebug('Row ' . $row['username']);
$userinfo[] = $row;
}
if (count($userinfo) == 1 )
{
$row = $userinfo[0];
$salt = openssl_random_pseudo_bytes(64) ;
if (crypt($password, $salt) == crypt($row['password'], $salt))
{
//set session id
session_start();
$app['session']->set('user', array('username' => $username));
return $app->render('myshows.php'/*, array(
'names' => $usernames ) */
);
}
else
{
return $app['twig']->render('login_form.twig', array('incorrectlogin' => 1 ));
}
}
if ($userinfo == null )
{
return $app['twig']->render('login_form.twig' , array(
'incorrectlogin' => 1 ));
}
}) ;
And this is my current php.ini file:
; php options
date.timezone = UTC
session.auto_start = 0
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
session.auto_start
is disabled. – Federkunsession_start();
. Symfony2 start the session by itself. – Federkun