www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to reset the website when the user leaves it, with vibe.d?

reply vnr <cfcr gmail.com> writes:
Hello 😊

I have a bit of a problem that seems simple enough, but I can't 
find an answer to my questions. On my website, I have two 
textareas that the user can write on. When the user reloads the 
page or closes it and then reopens it, the text he wrote is still 
written, which is quite annoying.

So my question is how to reset the website (the page) when the 
user reloads or quits.

I've looked at the vibe.d's sessions, because that's probably 
where the answer to my question lies, but from what I understand, 
it requires a "login and logout form" (at least, all the code 
examples do this), which I don't want, because I want the website 
to be accessible without logging in.

Do you have any ideas on how to fix this, probably with sessions?
Jun 29 2021
parent reply WebFreak001 <d.forum webfreak.org> writes:
On Tuesday, 29 June 2021 at 16:25:09 UTC, vnr wrote:
 Hello 😊

 I have a bit of a problem that seems simple enough, but I can't 
 find an answer to my questions. On my website, I have two 
 textareas that the user can write on. When the user reloads the 
 page or closes it and then reopens it, the text he wrote is 
 still written, which is quite annoying.

 So my question is how to reset the website (the page) when the 
 user reloads or quits.

 I've looked at the vibe.d's sessions, because that's probably 
 where the answer to my question lies, but from what I 
 understand, it requires a "login and logout form" (at least, 
 all the code examples do this), which I don't want, because I 
 want the website to be accessible without logging in.

 Do you have any ideas on how to fix this, probably with 
 sessions?
this is a client behavior that is implemented by some browsers, it has nothing to do with vibe.d. Set autocomplete to off to fix this: https://stackoverflow.com/questions/2486474/preventing-firefox-from-remembering-the-input-value-on-refresh-with-a-meta-tag
Jun 29 2021
next sibling parent WebFreak001 <d.forum webfreak.org> writes:
On Tuesday, 29 June 2021 at 19:05:43 UTC, WebFreak001 wrote:
 [...]
I should add that this is a convenience feature for users and you should avoid setting this unless it absolutely doesn't make sense that stuff is prefilled for the user. It's there to keep input in case you accidentally refresh the page.
Jun 29 2021
prev sibling parent reply vnr <cfcr gmail.com> writes:
On Tuesday, 29 June 2021 at 19:05:43 UTC, WebFreak001 wrote:
 On Tuesday, 29 June 2021 at 16:25:09 UTC, vnr wrote:
 Hello 😊

 I have a bit of a problem that seems simple enough, but I 
 can't find an answer to my questions. On my website, I have 
 two textareas that the user can write on. When the user 
 reloads the page or closes it and then reopens it, the text he 
 wrote is still written, which is quite annoying.

 So my question is how to reset the website (the page) when the 
 user reloads or quits.

 I've looked at the vibe.d's sessions, because that's probably 
 where the answer to my question lies, but from what I 
 understand, it requires a "login and logout form" (at least, 
 all the code examples do this), which I don't want, because I 
 want the website to be accessible without logging in.

 Do you have any ideas on how to fix this, probably with 
 sessions?
this is a client behavior that is implemented by some browsers, it has nothing to do with vibe.d. Set autocomplete to off to fix this: https://stackoverflow.com/questions/2486474/preventing-firefox-from-remembering-the-input-value-on-refresh-with-a-meta-tag
Thanks a lot for the explanations, I didn't know the autocomplete="off" tag. Nevertheless, the problem persists and seems to be even deeper, indeed, my site is hosted on Heroku and I can see what a user who is on another machine has written (behavior I just found out). Fortunately, this little site is only for entertainment purposes, but it is a behavior that seems quite vicious. If you want to access the code, it is on [this repository](https://github.com/noc-lang/playground) (it is just a playground for the language of a friend).
Jun 29 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 6/29/21 4:25 PM, vnr wrote:

 Nevertheless, the problem persists and seems to be even deeper, indeed, 
 my site is hosted on Heroku and I can see what a user who is on another 
 machine has written (behavior I just found out). Fortunately, this 
 little site is only for entertainment purposes, but it is a behavior 
 that seems quite vicious.
 
 If you want to access the code, it is on [this 
 repository](https://github.com/noc-lang/playground) (it is just a 
 playground for the language of a friend).
 
Has nothing to do with sessions, you are saving the text posted, and then making it the default text whenever the page is rendered. [here](https://github.com/noc-lang/playground/blob/0ec136b385c9aff306e15947082210d3bc230d 0/source/app.d#L68) is where you save the text. [here](https://github.com/noc-lang/playground/blob/0ec136b385c9aff306e15947082210d3bc230d10/s urce/app.d#L50-L52) you pass it to the template, and [here](https://github.com/noc-lang/playground/blob/d6551e8a5f90b8ebc1732c6dfb72ba61113887af views/home.dt#L128) you render it as the child of the text area. Just don't do that ;) -Steve
Jun 29 2021
parent vnr <cfcr gmail.com> writes:
On Tuesday, 29 June 2021 at 20:40:29 UTC, Steven Schveighoffer 
wrote:
 On 6/29/21 4:25 PM, vnr wrote:

 [...]
Has nothing to do with sessions, you are saving the text posted, and then making it the default text whenever the page is rendered. [here](https://github.com/noc-lang/playground/blob/0ec136b385c9aff306e15947082210d3bc230d 0/source/app.d#L68) is where you save the text. [here](https://github.com/noc-lang/playground/blob/0ec136b385c9aff306e15947082210d3bc230d10/s urce/app.d#L50-L52) you pass it to the template, and [here](https://github.com/noc-lang/playground/blob/d6551e8a5f90b8ebc1732c6dfb72ba61113887af views/home.dt#L128) you render it as the child of the text area. Just don't do that ;) -Steve
Ah, yes! Thanks a lot for pointing out the concerns, it was pretty simple. I understand better, thank you both :)
Jun 29 2021