Question

I have a helper method that returns a captcha image url & stores a session of the key:

function captcha(){
  $builder = new CaptchaBuilder;
  $builder->build();
  Session::put('phrase', $builder->getPhrase());

  return $builder->inline();
}

The user then writes the captcha and submits the form and my controller grabs all and validates it:

'captcha' => 'required|same:'.Session::get('phrase')

The problem is no-matter what it always says they phrase & the textbox submission are not the same... I can give more information if needed, also if this is not the best way to do it please give me suggestions, I am just learning Laravel4.

Edit for some output info:

If I return the values from the controller:

return "Session:".Session::get('phrase')." - Input:".$input['captcha'];

It returns: Session:5zij5 - Input:5zij5

Was it helpful?

Solution

According to Laravel's docs, same refers to another input.

I'd recommend using a custom validation rule to compare the session and the input.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top