set a Cookie for a restful service?

I’m trying to write a server and make use of the session id. i[/i]
When a request url comes to the server i may want the request to be handled by an existing session with that session identifier.
I assume cookies are the way this is done.


If the url doesn’t have an identifier parameter then a cookie must be given to the client that contains that identifier and the client.
Then the client can use the value of that cookie as part of the url for subsequent requests to the server.


So given that the session open event is the one who knows it’s identifier how does the App know the identifier to put in the cookie?

The idea being that the servers sessions need to be stateful and this is what I’m trying to achieve and i’d like to be able to connect back to a server and get the web page back in the same state and avoid destroying the session between url calls to it.

You’re right about the technique but I wouldn’t call it a cookie, rather just a session ID.

A cookie is typically used at the end user level by a browser, stored locally, and supplied in the header of HTTP requests. A session ID is supplied as a field in the URL or a POST (form-style) field for API access of a restful service.

otherwise, yes.

@Brian O’Brien I’m confused by your question, you call it a restful service but then talk about using Session and getting back to the web page.

Is it a “normal” web app where a user visits the app and gets pages to interact with?

Or is it an API service (maybe using HandleSpecialUrl) where you want to return JSON, XML or whatever?

Its a service … however returning simply json or xml is not what I have in mind, i wanted to present the user with a web page of the WebPage class in Xojo. I want the session to remain alive until there is a timeout if the user closes the page they can reopen if they have the session id. Which probably doesn’t need cookies?