changes session management way to use database