-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookies on WebTextTerminal #32
Comments
Found a solution editing file Adding on top: And then on bottom:
Then finally inside
From here the forward becomes then possible to read/write the cookies from each web request and generate the memory persistent data. Should also permit to recognize paths and work a bit more as a webpages. Here is an example for writing a cookie from the
Question: Is it worth doing a pull request with these modifications? On the local command line interfaces is possible to write things on disk, on the web browser we are limited to these methods. An idea could be perhaps to provide a "properties" method that can save these tidybits of data either on disk or as cookies depending on what is used? Again, thanks for the great library. It is a fantastic piece of work. |
That's a great solution. A pull request is more than welcome. Thanks! |
Will do. If possible, need your opinion. It is possible to set the cookies only until the first terminal command is sent. After that it does not seem possible to send cookies any longer using the context object. For example:
Key1 gets written to the cookies on the browser page. But key2 will be ignored, albeit still listed inside the context list when applying: It seems that after a communication with the browser that the context objects loses "context", and some other object is created instead. I was looking where to catch it but I'm unable to find the right location. Would you have any ideas where to inject the cookie info for the browser? |
Hello, I've created a hack. Meaning that a static map list is created with the list of current SESSIONIDs and which cookies should be written. Then before sending a reply the cookies are written back on the proper response object. I've started uploading the code, so this technique is visible here: https://github.com/nya-official/nya-server/blob/main/src/main/java/org2/beryx/textio/web/RatpackDataServer.java#L227-L233 It works albeit not exactly an efficient solution. Just sharing in case you have some thoughts on how to solve this better within textIo. |
I think your hack is ok. I don't have a better solution. |
Hello,
Was able to make progress quickly, the command line app is looking great thanks to Text-IO.
What is now missing is persistent memory. This can be done on the swing and command line interfaces very easily using files on disk for storage to remember a user that is logged, but not so trivial for the WebTextTerminal because the ContextHandlers don't seem to be exposed for usage. Otherwise would be possible to solve this by extracting URL paths and cookies.
Perhaps exposing the Context object from Ratpack is the simplest way? I imagine it is not easy to create a common mechanism for both spark and ratpack, on this case just needed for RatPack.
How would you recommend that we can access cookies and the URL from within Text-IO for the purpose of persistent user-memory? (to know who is logged inside the app).
Again: many, many thanks. Really good library.
The text was updated successfully, but these errors were encountered: