Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional path param to consent_api_set_cookie #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions assets/js/wp-consent-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ function wp_has_consent(category) {
/**
* Set cookie by consent type.
*
* @param {string} name The cookie name to set.
* @param {string} name The cookie name to set.
* @param {string} value The cookie value to set.
* @param {string} path The cookie path to set.
*/
function consent_api_set_cookie(name, value) {
function consent_api_set_cookie(name, value, path = '/') {
var secure = ";secure";
var days = consent_api.cookie_expiration;
var date = new Date();
Expand All @@ -62,7 +63,7 @@ function consent_api_set_cookie(name, value) {

if (window.location.protocol !== "https:") secure = '';

document.cookie = name + "=" + value + secure + expires + ";path=/";
document.cookie = name + "=" + value + secure + expires + ";path=" + path;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion assets/js/wp-consent-api.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.