import pickle
import codecs


def get_search_attributes_from_session(request):
    """
    Retrieve the search attributes from the session and returns them.
    :param request: django request attributes
    :return: search attributes stored in the session
    """
    query = request.session['query']
    query_values = pickle.loads(codecs.decode(request.session['query_values'].encode(), "base64"))
    display_headers = pickle.loads(codecs.decode(request.session['display_headers'].encode(), "base64"))
    order_by = request.session['order_by']
    limit = request.session['limit']

    return query, query_values, display_headers, order_by, limit