adding session and database function