Question

I have validated and authenticated a user and upon authentication I redirect him to the 'dashboard view file'.

What I want know is how do I send that user's data along with the redirected command.

My function looks like this:

if($validator->passes()) {
/-- validate user --/
return Redirect::to('users/login')->with('message', 'Thanks for registering!');

I would appreciate it if someone helped me add the user's data.
Thanks

Was it helpful?

Solution

You can pass it:

$user = User::find(1);

return Redirect::to('users/login')
       ->withMessage('Thanks for registering!');
       ->withUser($user);

And get it in your controller

$user = Session::get('user');

Or you could just pass the id

return Redirect::to('users/login')
       ->with('message', 'Thanks for registering!');
       ->with('user_id', $user->id);

And search for it again

$user = User::find(Session::get('user_id'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top