def getvar(request, field_name, setsession=False):
    """Check field in POST/GET request and return field value
    if there is value you can also save a session variable
    """
    if request.method == 'GET':
        if field_name in request.GET:
            val = request.GET[field_name]
        else:
            val = ''
    if request.method == 'POST':
        if field_name in request.POST:
            val = request.POST[field_name]
        else:
            val = ''
    if setsession and val and val != '':
        request.session['session_' + field_name] = val
    return val
