You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-22Lines changed: 61 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# UK.NHS.CookieBanner
2
2
3
3
# Cookie Banner NuGet Package for .NET Core
4
-
This NuGet package provides an easy-to-use cookie banner for .NET Core web applications. The cookie banner allows you to comply with the EU Law and the GDPR by informing users about the use of cookies on your website and giving them the option to accept or decline cookies.
4
+
This NuGet package provides an easy-to-use cookie banner and cookie policy page for .NET Core web applications. The cookie banner allows you to comply with the EU Law and the GDPR by informing users about the use of cookies on your website and giving them the option to accept or decline cookies.
5
5
6
6
It is designed to work with API calls, SQL server, and custom classes.
7
7
@@ -12,8 +12,10 @@ You can install the package via NuGet Package Manager or by running the followin
12
12
Install-Package UK.NHS.CookieBanner
13
13
````
14
14
15
-
## Usage
15
+
# Usage
16
16
17
+
# Implementing Cookie Banner
18
+
## How to Implement Cookie Banner
17
19
### Update _Layout.cshtml file
18
20
19
21
In your _Layout.cshtml file (or any other view where you want to display the cookie banner), add the following code
@@ -31,45 +33,82 @@ Need to add in Header section nhsuk.css if it doesnt exist
There is a possibility of utilising various sources to populate the cookie policy content through different means, including calling APIs, using a SQL server, or implementing a custom approach.
To configure the "CookiePolicy" section in your appsettings file, you need to provide the appropriate values for each property. Here's an explanation of each property:
#### Get cookie policy content from SQL based source
56
-
57
-
```bash
61
+
- "ConnectionStringName": Specify the name of the connection string from your "ConnectionStrings" section that will be used to connect to your database.
62
+
- "CookiePolicySQL": Specify the SQL query that will retrieve the cookie policy information from your database.
63
+
- "UpdatedDateSQL": Specify the SQL query that will retrieve the last updated date of the cookie policy from your database.
64
+
```bash
58
65
"CookiePolicy": {
59
66
"ConnectionStringName": "", // Connection name specified in "ConnectionStrings"
To configure the "CookiePolicy" section in your appsettings file, you need to provide the appropriate values for each property. Here's an explanation of each property:
81
+
82
+
83
+
- "ApiUrl": Specify the URL of the API that handles the cookie policy requests.
84
+
- "CookiePolicyRequestURI": Specify the URI or endpoint on the API that is responsible for managing cookie policy-related requests.
85
+
- "ClientIdentityKey": Specify the key or identifier used to authenticate the client making the cookie policy requests.
86
+
87
+
```bash
88
+
"CookiePolicy": {
68
89
"ApiUrl": "",
69
90
"CookiePolicyRequestURI": ""
70
91
"ClientIdentityKey": ""
71
92
}
72
93
```
94
+
95
+
# How to use this package in Existing Cookie Policy Page
96
+
97
+
If you wish to use your own policy page, please update the "ControllerName" and "ActionName" in the appsettings file. When using your own cookie policy, ensure that you utilise the existing cookie consent confirmation partial view. This view is responsible for updating analytical cookies and the user consent cookie.
98
+
99
+
```bash
100
+
@await Html.PartialAsync("_CookiePolicyConfirmation", new CookieConsentViewModel {UserConsent = cookieBannerCookieValue, Layout = Layout})
101
+
```
102
+
```bash
103
+
"CookiePolicy": {
104
+
"ControllerName": "",
105
+
"ActionName": ""
106
+
}
107
+
```
108
+
109
+
- "ControllerName": Specify the name of the controller that will handle the Cookie Policy page logic.
110
+
- "ActionName": Specify the name of the action method within the specified controller that will render the Cookie Policy view.
111
+
73
112
74
113
## Contributions
75
114
Contributions are welcome! Please feel free to submit issues and pull requests.
0 commit comments