简体   繁体   中英

Session Started By PHP

I'm trying to load a form in my controller and I fail out when it tries to get the form view. The error I get says that the session has already been started by PHP. I have the session auto start directive in php.ini turned off already, so this isn't a problem. and other pages where I use the session don't give me this error. any assistance?

EDIT: I'm adding my controller code and form code

$group = new Group; //Group is an Entity with just one get and set property
$group->setGroup(true);
$form = $this->createForm(new BlacklistGroup(), $group);
$vars['form'] = $form->createView();

Form class BlacklistGroup

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'Facebook\ContestBundle\Entity\Group',
    ));
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('group','checkbox',array(
                'label'     => 'Show this entry publicly?',));
    $builder->add('save', 'submit');
}

public function getName()
{
    return 'group';
}

somewhere you're calling session_start() twice - perhaps in the model and view? Look at all your files and see where it's repeating.

Are you using include() or require_once() when you include your config file? I typically call session_start() only in my config file because of this type of thing. :)

use include_once or require_once instead of include or require, if you are using them! Or else you have session_start() declared twice in your page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM