-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All LaravelShoppingcart methods don't work when using api call in laravel #367
Comments
I need more information to debug this. Are the API calls using a session or not? What is the code you use, which version of Laravel and this package. How can I reproduce this problem. Otherwise I can't help you. |
I'm using Redis driver with laravel 5.4
I access to my api in browser like this : www.example.com/api/test
I get content but when i delete the line Cart::add :
I can't get old session data, i get nothing |
Any idea please that can help me? it's like that a new session created or something like that, Can you help me? |
@leonfather Laravel routes in |
@matejsvajger I still get the same problem |
Does the normal laravel session work? Can you put something in the session and retreive it? |
yes it works i'm using redis in session I store my session data using |
That's not the Laravel session you're using. You're using Redis directly, and not via the session manager (which this package is using) Try with the Session facade please |
i'm using session facade i only change SESSION_DRIVER=redis from file to redis |
But when i'm doing test to see if laravel session work or now i get those results :
in the same route /test i get result : value |
@leonfather you're setting and retrieving the session value in the same call. Try retrieving it in a different function. |
yes i'm doing tests now and laravel session works fine, Any idea from where i get the problem ?
cart/index.blade.php (cart file)
vue js file :
|
in CartController in index method :
With this code i get content in cart but if i comment Cart::add(18,...... i get nothing in cart content |
I have the same problem with cart, any help will be appreciated |
I had this problem just now and this is how I fixed it. First you need to change the api middleware group to:
in
It is important that all entries are there and that they are in this order. |
well 3 things you need to observe since im using this basically for vue SPA, and using api calls... |
The API is |
Hi @codeitlikemiley, I'm creating a Vue SPA. I've switched to the web routes, but Are you using sessions? |
use Illuminate\Http\Request; |
Is this still an isue for anyone else? |
It's still an issue for me. When I add those middlewares to 'api' group, it brakes Passport auth:api system. The workaround solution is to move shopping cart routes to web.php, wherein 'web' middleware session already exists and retrieves cart correctly. |
I found a solution by inserting the 'web' middleware in the api routes.php Route::group([
'middleware' => ['web'],
'prefix' => 'api',
'namespace' => 'Api\Http\Controllers'
], function () { hope that helps |
Hello i have i problem and i can't resolve it All LaravelShoppingcart methods don't work when using api call in laravel to retrieve session data? Any idea?
The text was updated successfully, but these errors were encountered: