added errors in sessions and redirect function