Could not find the current session id in the cookies

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)

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

Does anyone knows what can cause the problem?

Shopify Partner
20 0 15

@olaide Have you solved the issue somehow?

Shopify Partner
1 0 0

@olaide @Happiness  has anyone resolved this issue?

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.



Here is a nice solution: