Hello Everyone, I want to use sessions in glue APIs, Is there any way to have that??
Hello Everyone,
I want to use sessions in glue APIs, Is there any way to have that??
Comments
-
In theory you could pass the session id as a header/cookie as it is done in Yves.
But why would you do that? Glue is designed as REST/JSONAPI API, which is by definition stateless and sessions are stateful.
Maybe you can elaborate what you want to achieve, I'm sure there is a better alternative then using the session in Glue.0 -
Here is the scenario, I have two APIs API_1 and API_2.
In an API_1 I have a request param
xyz
with value123
and in API_2 I have a response param XYZ.
So if someone hit the API_1 with paramxyz
value123
, API_2 will populate the same value in the return response.0 -
And why do you need a session for that? In API_1 create a storage entry for xyz (https://github.com/spryker/storage/blob/master/src/Spryker/Client/Storage/StorageClientInterface.php#L31) and in API_2 you read the storage entry for xyz (https://github.com/spryker/storage/blob/master/src/Spryker/Client/Storage/StorageClientInterface.php#L89).
If you need a permanent storage you should instead save the value of xyz in the Zed database and either read it from their or write it to the storage at the same time for fast access.0 -
But params will vary end to end for each person or device.
0 -
-
you could build the storage key in a manner to include the person and device (e.g.:
kv:<person>:<device>:xyz
.
But I still don't get why you have one API to write and one to read for values that are bound to an individual session (person & device). In those cases it could make sense to not store the value at all in Spryker but only on the device.0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 βοΈ - Guardians (admin)
I would also highly advice against introducing sessions to Glue. From IT architecture view this does not make sense at all to introduce sessions to a restful api imoβ¦. I would rather work with tokens or what Alberto suggests
0 -
Thanks for it, I am considering this.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 896 Developer Corner
- 758 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 23 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random