Setting values in cookies using javascript

I am developing a web portal and want to set some values to the cookies from the javascript in order to quickly load the web page with user specific preferences.

I am using this code, but unable to set the cookie value. some minute issue with this, but not sure what.

document.cookie = `${cookieName}=${JSON.stringify(cookieObject)};path=/;SameSite=Strict;expires=${someDate.toUTCString()};`