Sets a device name in a cookie when a user explicitly wants to go
    to the site for a particular device (eg mobile).

def set_device(request, device=""):
    """
    Sets a device name in a cookie when a user explicitly wants to go
    to the site for a particular device (eg mobile).
    """
    response = redirect(add_cache_bypass(next_url(request) or "/"))
    set_cookie(response, "yacms-device", device, 60 * 60 * 24 * 365)
    return response