The userid and password cookies are not set when one logs in if they haven't clicked the remember me button. So, using the script you have above, if the cookie check fails, then provide a login prompt. I'm assuming this script is based on
David Groves' external login tutorial so that part should be trivial. Remove the remember me option and hardcode remember in the login script. This will force the cookies to be set and you will be off and running.