Don't use $_SESSION. That's the native PHP session, which is not used by Laravel.
FYI: Tried using middleware as web
Are you trying to say you're using the web middleware group? You must use it, because the api middleware group is stateless, i.e. it doesn't include the StartSession middleware.
Note that any changes you made to the session are automatically saved at the end of the request by the StartSession middleware. If you terminate the request by calling die() or exit() or something like that, the changes will never get saved.
The app which I am developing will be loading inside a iframe inside bigcommerce panel.
Most browsers nowadays block 3rd party cookies by default. That means your session cookies won't work in an iframe. You have to set the cookie's SameSite attribute to None if you want it to work in an iframe. Laravel has a same_site entry in the session.php config file for this.
The reason why $_SESSION worked could be due to the samesite settings in your php.ini.
If at all possible, I'd get away from iframes. 3rd party cookies may get completely blocked for some users, or they might not work in incognito mode. Iframes are also bad from a UX standpoint. But if you absolutely have to to embed your app, you should have secure Content Security Policy settings, so that only the specified domain can embed your website. That way other sites can't put your site in an iframe and try to run some clickjacking scam or similar.