0

Does anyone have a good place to start with?

I want to manage sessions to prevent reading and writing data to the DB in every HTTP/HTTPS request i get.

The catch is that requests come from a PHP server and not from a browser. I can provide more details if needed, but really want to now if someone has tackled this already...

EDIT 1:

The PHP server will send many requests to my nodeJS and the requirement is that each request will have its own sessions parameters stored separately.

TBE
  • 1,002
  • 1
  • 11
  • 32

1 Answers1

0

Sessions are based on cookies, if your HTTP client (in this case, a PHP script using cURL or whatever) supports cookies which persist between requests, your sessions will work just as they do with normal browsers.

If your client does not support cookies, your sessions will not work, regardless of how hard you try.

Community
  • 1
  • 1
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • What about generating a session ID and an object that maps between the session ID i generated and the session's parameters i want to store for that session? – TBE Nov 20 '15 at 14:21
  • There are express libraries that do that. But those won't help you when the client doesn't support persistent cookies (PHP does not have persistent memories between requests. So unless it's a long, continuous script that sends out multiple requests to your server, it won't support persistent cookies). – Madara's Ghost Nov 20 '15 at 14:22
  • i just edited my question to add that the PHP will send multiple requests and each request should have a separate session. – TBE Nov 20 '15 at 14:25
  • You aren't making sense. If each request has its own session, how will that save anything in terms of DB I/O? – Madara's Ghost Nov 20 '15 at 14:26
  • Let me explain my self a bit better. The PHP server can start a "conversation" between himself and my nodejs. Each "conversation" can go back and forth multiple times and needs to have a session. The PHP can initiate multiple conversations of that kind with the nodejs. I'm building the nodejs side, but also managing the PHP development as well so i can ask the PHP developer to do what ever is needed. – TBE Nov 20 '15 at 15:28
  • @TomerBenEzra: You don't need to do anything server-side. It's the client-side (PHP) that will need to sweat. – Madara's Ghost Nov 20 '15 at 15:29