Re: How get session object in a non request context

Solved

How get session object in a non request context

ZiedDams
Shopify Partner
8 2 0

let say we are in a Handler class of a webhook

 

class ProductsHandler implements Handler
 
{
public function handle(string $topic, string $shop, array $body): void{
 switch ($topic) { 
case Topics::PRODUCTS_CREATE: {
// how to get a session instance here so we can perform shopify api call
//
//  $session = ?
//$client = new Rest($session->getShop(), $session->getAccessToken());
 
 
}
 }
 }
}
Accepted Solution (1)

ZiedDams
Shopify Partner
8 2 0

This is an accepted solution.

i found a solution

as we already have the $shop variable so  we can do this

$session = Utils::loadOfflineSession($shop);

 

View solution in original post

Reply 1 (1)

ZiedDams
Shopify Partner
8 2 0

This is an accepted solution.

i found a solution

as we already have the $shop variable so  we can do this

$session = Utils::loadOfflineSession($shop);