using System.Web;
using Umbraco.Core;
namespace Umbraco.Web
{
///
/// Extension methods used to check/set cookie values
///
///
/// This should 100% supercede the StateManager.Cookies
///
internal static class HttpCookieExtensions
{
internal const string PreviewCookieName = "UMB_PREVIEW";
///
/// Does a preview cookie exist ?
///
///
///
public static bool HasPreviewCookie(this HttpRequestBase request)
{
return request.Cookies[PreviewCookieName] != null;
}
///
/// Does a cookie exist with the specified key ?
///
///
///
///
public static bool HasCookie(this HttpRequestBase request, string key)
{
return request.Cookies[key] != null;
}
///
/// Is there a cookie with the key supplied and does it have a value that is not empty
///
///
///
///
public static bool HasCookieValue(this HttpRequestBase request, string key)
{
return request.Cookies[key] != null
&& request.Cookies[key].Value != null
&& request.Cookies[key].Value.IsNullOrWhiteSpace() == false;
}
}
}