Page 2 of 2
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:30 pm
by dunbarx
One cannot use global variables to store anything that needs to survive sessions. Globals do not; they must be populated each and every time. Such data should be either in a field, a custom property or an external file. If you have concerns about security, though it sounds like you do not, let us know.
Craig
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:31 pm
by Klaus
Code: Select all
global gChosenName,gChosenPassword
## Better use another name for this handler, since it is not (yet) the LOGIN handler
## Of course you can and should change the handler and variable names to fit your needs.
on SetUserNamePWD
ask "What username do you want?"
put it into gChosenName
ask "What password do you want"
put it into gChosenPassword
end SetUserNamePWD
Then you can later use these globals to compare.
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:33 pm
by dunbarx
Klaus.
Why are you still set on using globals? These die every time you quit LC.
Craig
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:37 pm
by stam
As Richard mentioned earlier, it's good practice not to store the password per se, but a 1-way hash of it (so that the password cannot be divined from stored data). When the user enters a password it should be hashed in the same way to compare with the stored hash if that makes sense...
look at messageDigest in the dictionary...
S.
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:41 pm
by Klaus
dunbarx wrote: Thu Sep 08, 2022 2:33 pm
Klaus.
Why are you still set on using globals?
I didn't expect the spanish inquisition!
dunbarx wrote: Thu Sep 08, 2022 2:33 pm
These die every time you quit LC.
Why didn't anybody tell me?
Yes, sorry, Craig, pure lazyness, of course one needs to save these globals somewhere before quitting LC.
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:44 pm
by stam
dunbarx wrote: Thu Sep 08, 2022 2:33 pm
Why are you still set on using globals? These die every time you quit LC.
It may a useful intermediary step, if for example there is a subsequent handler that stores the password. And of course the OP is just using this for test purposes
However in this context i would probably avoid using globals anyway, just a script local (ie replace the the 'global' keyword with 'local' - it then becomes a variable that is 'global' for the script only and available to all handlers below it).
S.
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 2:54 pm
by Curiousbystander
Thank you all for educating me.
It's working now, thank you again.
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 3:04 pm
by Klaus
I highly recommend these stacks to get a grip of the basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html
Re: Based on this code, how would I make a register button
Posted: Thu Sep 08, 2022 3:37 pm
by dunbarx
@Klaus
Ha. Nobody does.
@CuriousBystander. It is important to understand these points, that is, security and also how to store data in your stacks. For the data, no variable of any kind will survive a new session. Your options are the three I mentioned earlier. I think you should practice using custom properties. They are wonderful and can store any kind of data.
Craig