CaptchaBundle icon indicating copy to clipboard operation
CaptchaBundle copied to clipboard

"Code does not match" when using PHP built-in web server

Open BruceWouaigne opened this issue 10 years ago • 2 comments

Hi folks, I'm on this issue since 2 days and i'm really stuck! Here is the thing.

There is a simple "sign-up" form which use the captcha type.

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('email', 'email', [
                'label' => 'all.email'
            ])
            ->add('plainPassword', 'repeated', [
                'type'            => 'password',
                'invalid_message' => 'all.password_mismatch',
                'first_options'   => ['label' => 'all.password'],
                'second_options'  => ['label' => 'all.password_confirm']
            ])
            ->add('captcha', 'captcha')
            ->add('submit', 'submit', [
                'label' => 'all.submit'
            ])
        ;
    }

Using my Apache Web Server, everything is fine. When I type a bad captcha I got insulted, when I type a good one my account is created.

Using the PHP built-in web server app/console server:run I always get insulted!

Using Apache, I've figured out the following workflow:

  1. A new captcha is generated
  2. The captcha is stored in the Session
  3. Form submission (the page is reloaded)
  4. The captcha is retrieve from the session (and is equal to the one stored on step 2.)
  5. The retrieved captcha is compared to the form input value
  6. Done

Using PHP Web Server:

  1. A new captcha is generated
  2. The captcha is stored in the Session
  3. Form submission (the page is reloaded)
  4. The captcha is retrieve from the session --> but this time different form the one stored on the step 2!!
  5. The retrieved captcha is compared to the form input value
  6. Done

Any ideas?

Thanks.

BruceWouaigne avatar May 09 '14 16:05 BruceWouaigne

I already noticied that the session handling is a little bit erratic in the built-in server

What is your PHP version?

Gregwar avatar May 12 '14 10:05 Gregwar

5.5.3

BruceWouaigne avatar May 12 '14 14:05 BruceWouaigne