Added cookie session key. Fixed db close bug.