def is_current_session(session, request):
    """
    Checks if a given session object is the same as the on used by the request.

    :type session: :class:`django.contrib.sessions.backends.base.SessionBase`
    :type request: :class:`django.http.HttpRequest` or None
    """
    if request is not None:
        return session.session_key == request.session.session_key
    return False
