I'm writing a series of MATLAB functions which communicate with a server through urlread. Each function in this package that makes this call requires an authentication username and key.
I would rather not require the user to pass in the username and key when calling every function. Instead, I prefer to have a signin(username, key) function that sets/saves these variables in such a way that each function in this package can recall.
My solution right now is for signin.m to save username and key to a temporary file and to modify finish.m to erase this temporary file when MATLAB closes. Each function in the package would load these variables from that temporary file. However, if someone force quits MATLAB, this temporary file will not be erased (right?).
Another solution was to have signin save username and key as global variables. However, if a user calls clear all, these variables will be removed the workspace and the user will need to call signin again (which is a nuisance).
Is there some way to set 'session' variables that are global and are not removed with a clear all command? Any other suggestions?