Get current username / Session in scripting in perspective

The ugly, hacky, unsupported, completely-liable-to-break-on-any-upgrade way to get magical access to the current session is using a public static ThreadLocal, as mentioned here:

As my first sentence alludes - this is a bad practice, liable to break at any time.