Could not find the current session id in the cookies

olaide
Visitor
1 0 6

I started having this error from my shopify app Oauth implementation sometime last week.

I am using the shopify/shopify-api PHP package for this implementation.

 

The below implementation is from the callback url supplied in the shopify app settings

try {
$callback = OAuth::callback(
cookies: \request()->cookies->all(),
query: \request()->input(),
);
} catch (\Throwable) {
return \redirect()->intended(request()->headers->get('referer'));
}

 

The error log shows as follows:

 

Shopify\Exception\CookieNotFoundException: Could not find the current session id
in the cookies in /var/www/pac/releases/260/vendor/shopify/shopify-api/src/Auth/OAuth.php:277

Stack trace: #0 /var/www/pac/releases/260/vendor/shopify/shopify-api/src/Auth/OAuth.php(124): Shopify\Auth\OAuth::getCookieSessionId() #1 /var/www/pac/releases/260/app/Http/Api/V1/Controllers/Shopify/ShopifyController.php(81): Shopify\Auth\OAuth::callback() #2 /var/www/pac/releases/260/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Api\V1\Controllers\Shopify\ShopifyController->authCallback()

 

Replies 4 (4)

Happiness
Shopify Partner
20 0 15

Hi! I've started to receive the same error. Looks like it works fine when run in dev but when build a production version it will show this error. The issue is the same for the app developed five month ago and for a fresh app built on a PHP 8 with this package https://github.com/Shopify/shopify-app-template-php/tree/main

Does anyone knows what can cause the problem?

Happiness
Shopify Partner
20 0 15

@olaide Have you solved the issue somehow?

cmarini26
Shopify Partner
1 0 0

@olaide @Happiness  has anyone resolved this issue?

Edwin_Oxilayer
Shopify Partner
3 0 0

This error occurs when user clicks on a "Install" app button, and stays longer than 1 minute in authorization page, then  the cookie "shopify_session_id" expires and this error shows up.

 

Update:

Here is a nice solution: https://github.com/Shopify/shopify-api-php/issues/143#issuecomment-1709052833