GH SDK events & gh Python

I’m trying to write a simple login script that takes the current users username and password and validates them using ctypes.windll.advapi32.LogonUserW(). To save the information about a successful login i put a key-value pair in sc.sticky like sc.sticky[‘valid_user’] = True.
I realize this is not an optimal solution and that it won’t be particulary secure but I’m exploring it as a “quick and dirty” option to make a full webbased login against a remote server.

I have 2 issues with this approach:

  1. sc.sticky is not tied to the ghdoc, which means that information in the sticky can be shared between multiple open documents - is there a better option? Something that lets me store data but somewhere within the document?

  2. since it’s not tied to the document, the very least I would like to do is to clear the sc.sticky when the document is closed. For this i’ve been looking to use the event GH_documentServer.DocumentRemoved. This event doesn’t seem to function the same way like rhinodoc events, which are the only ones I’ve found examples of using ghpython - can Grasshopper API events be used with GH-python? If so, I would be very greatful for an example of how to achieve this.

You could use the if “foo” not in globals() method for storing a persistent flag. This works similar to sticky, but with a scope that’s local to one GHPython component.