added check for user
added session insert logic