0

Does anyone know of a way to have redirect variables persist while a user is logging in via Facebook or Google. This has puzzled me for a while now.

For example if I want to redirect the user back to a specific article (page) on the website I need the URI information to persist during the login.

The problem is that the login process takes the user to the provider (in my case Facebook or Google) and then back to the website. During which time the redirect information is lost.

Does anyone know of a way to do this?

All help is appreciated.

Thanks, cs1h

cs1h
  • 475
  • 1
  • 5
  • 8
  • 1
    Just a thought: Maybe you can save the redirect information your self inside the session before you redirect the user to Facebook or Google. You could do this with the Session::put('key', 'value'); option. After the user comes back to your application you could redirect them based on the saved session value. Dont forget to add 'use Session;' to your controller to use 'Session::put'. After that you can also unset the session value again with 'Session::forget('key');'. – Jirennor Oct 14 '15 at 14:39
  • Hi Thomas, I tried to put it into the session but it doesn't seem to persist. I assume it is going missing because the script goes from the website, to the provider (for example Google) and then back to the website. Would you expect the Session to persist in this flow? Thanks. – cs1h Oct 14 '15 at 14:43
  • I would expect that it would persist as long you come back to the same domain (URL). Your browser creates a cookie for each domain. As far as i know those session items are stored in the cookie. So if you come back to the same URL you should have access to those session values. Example: http://example.com/login this will redirect to Facebook or Google. Facebook or Google redirects back to http://example.com/callback. So then you should have the same cookie thus session variables. – Jirennor Oct 14 '15 at 14:48
  • You can track your cookies in the debug console of Chrome under Resources. Maybe this will shed some light on it. – Jirennor Oct 14 '15 at 14:50
  • Hi Thomas, thanks for the information. I will have a deeper look into it and see where cookie is going wrong. – cs1h Oct 14 '15 at 15:07
  • Hi, I have tried the sessions again and I am having some weird behavior. I set the session value before it redirects to the provider (i.e. Google) and it is there but when I check the session upon return to the website, the session parameter is there but the data in it has been lost. Any ideas? Thanks. – cs1h Oct 14 '15 at 19:25
  • Sorry, ignore my last comment. It was being caused by something earlier in the process. It looks like the session will work. Thanks for your help. – cs1h Oct 14 '15 at 19:33

0 Answers0