Laravel Auth::check() fails when I move to another site and come back
Laravel Auth::check() fails when I move to another site and come back
I am trying to connect to a eBay store from my Laravel application. When I login to my system and create a store I am redirected to the eBay.com site where I approve the token generation.
Then eBay generates the token and redirects to the callback URL on my site. By that time my site gets me logged out and redirect to the login page.
The Laravel version I am using is 5.3 and following is the piece of code which checks for authentication. Also, I am using the default id column as primary key.
if (Auth::check())
$loginUser = Auth::user();
$ebay_sessionId = $loginUser->ebay_session_id;
else
return redirect('/login');
Could you share some code to explain what you mean?
– Rinsad Ahmed
Aug 21 at 9:59
You have to share your code! Anyway I explain myself a little better... I think the application problem is the
Auth::check()
that is called before the user session is started... That's why I was asking you to post the code pre redirect to ebay and after the redirect– IlGala
Aug 21 at 10:06
Auth::check()
Is there a reason why you are not using Laravel's built in authentication?
– Chukwuemeka Inya
Sep 2 at 8:05
It is the built-in authentication. Here I am getting the user and the value associated with the user
– Rinsad Ahmed
Sep 2 at 8:17
2 Answers
2
You're not doing it in your browsers incognito mode are you? Otherwise it won't persist your session if it opens a new window/tab.
Not in incognito mode
– Rinsad Ahmed
Sep 5 at 2:52
I had a similar issue where sometimes my app was connected to default DB "forge" specified at "database.php" at config as follows
'database' => env('DB_DATABASE', 'forge'),
here I have removed "env" and put my DB name directly as follows and it worked.
'database' => 'my_db_name'
Since you have an issue with the session, give it a try by removing "env" at "session.php" at the config folder.
Hope this will work out.
That made the trick. Do you have any idea why it fails with env file? When I hard coded the session driver to 'file' it works but when I read from the env file it sometimes works but not otherwise. Have an idea?
– Rinsad Ahmed
Sep 6 at 1:44
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you also add the login process code? With the routes and the controller that it's handling it?
– IlGala
Aug 21 at 9:58