I use Laravel 5.3 and vue.js 2.0. So for this application I
would like to use sessions instead of jwt tokens. So when for example a user signs
in I would like to make an ajax call with vue.js. Is it possible to create a session then? And if the credentials are false showing error messages but without refreshing the entire page?
And for example if someone likes a post I would like to handle that with an ajax call aswel. But how would I do that if I only have a session. Do I have to use jwt tokens in that case?
A new Laravel 5.3 install is already set up to use sessions. Look here /vendor/laravel/framework/src/Illuminate/Session and here https://laravel.com/docs/5.3/session.
With the default configuration you would have your session cookie when you open your website and it would be sent with each request to the server, including your ajax requests, so you should be able to do what you want there.
if you want to show your error messages without reloading the page, just return a json response with the error in your authentication controller and show it in your ajax callback.
If your user likes a post, his session cookie will be sent with the ajax request so you will be able to know who it is. There is no necessity here to use jwt in your scenario. Did you face any troubles in your application with sessions?
@lars6 Your laravel app would start a session as soon as your user is opening one of your webpage. You can check with the developer tools in your browser, you'll get a cookie called "laravel_session" by default containing your PHP session ID.
The authentication has nothing to do with starting the session. It will just store in the user's already existing session that he is now loged in.
Also even if what's provided witth make:auth is a good place to start, I suppose you would have some customisation work to login using ajax as you won't want to load another page but just a "success" information to use in your vue component.
What do you mean? As I told you the user get a session as soon as he is viewing the website, so even before trying to login. It's all done for you, you don't have to do anything manualy. So here if your authentication attempt is ok it will be stored in the user session which already exists. Nothing to do yourself here.
What's your real question here ^^ ? I'm not sure to understand your problem.