From bdfb1a2e2d0ee1a8316d7997fce11ee50dfe0e1a Mon Sep 17 00:00:00 2001 From: amin52j Date: Mon, 8 Jul 2019 16:03:51 +0200 Subject: [PATCH] Adds cookieDomain property to set the domain name --- src/CookieBanner.tsx | 6 +++++- src/README.md | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CookieBanner.tsx b/src/CookieBanner.tsx index 2f04250..ee9954c 100644 --- a/src/CookieBanner.tsx +++ b/src/CookieBanner.tsx @@ -21,6 +21,8 @@ export type CookieBannerRequiredProps = { }, /** used to set the cookie path */ cookiePath?: string, + /** used to set the cookie domain */ + cookieDomain?: string, /** whether the cookie banner should be dismissed on scroll or not */ dismissOnScroll?: boolean, /** amount of pixel the user need to scroll to dismiss the cookie banner */ @@ -73,6 +75,7 @@ export default class CookieBanner extends React.Component { - const { cookies, cookie, cookieExpiration, cookiePath: path, onAccept } = this.props as CookieBannerDefaultedProps; + const { cookies, cookie, cookieExpiration, cookiePath: path, cookieDomain: domain, onAccept } = this.props as CookieBannerDefaultedProps; cookies.set(cookie, true, { path, + domain, expires: new Date(Date.now() + (this.getSecondsSinceExpiration(cookieExpiration) * 1000)) }); diff --git a/src/README.md b/src/README.md index 90fd4cc..e1a7409 100644 --- a/src/README.md +++ b/src/README.md @@ -13,6 +13,7 @@ React Cookie banner dismissable with just a scroll! | **cookie** | String | "accepts-cookies" | *optional*. Cookie-key used to save user's decision about you cookie-policy | | **cookieExpiration** | union(Integer | {years: ?Number, days: ?Number, hours: ?Number}) | { "years": 1 } | *optional*. Used to set the cookie expiration | | **cookiePath** | String | | *optional*. Used to set the cookie path | +| **cookieDomain** | String | | *optional*. Used to set the cookie domain | | **dismissOnScroll** | Boolean | true | *optional*. Whether the cookie banner should be dismissed on scroll or not | | **dismissOnScrollThreshold** | Number | 0 | *optional*. amount of pixel the user need to scroll to dismiss the cookie banner | | **closeIcon** | String | | *optional*. ClassName passed to close-icon |