Questions tagged [cookies]

A digital breadcrumb left by your web browser, an HTTP cookie holds valuable user information. With the versatility to be formed, accessed, manipulated, and eradicated via JavaScript or server-side using HTTP headers, cookies are powerful entities.

Tips for retrieving react-cookies when CORS is restricting access

Using react-cookies, I am trying to transfer data from the client side to the server side. However, when examining the request in NodeJS, I cannot locate any cookies in the headers or elsewhere. It seems that the cookies may not have been sent. After some ...

What is the best method for storing a multidimensional array in cookies using PHP?

cookie[person][name], cookie[person][id], cookie[person][age] What is the method to create a cookie with the specified structure? ...

Is it necessary to store tokens in cookies, local storage, or sessions?

I am currently utilizing React SPA, Express, Express-session, Passport, and JWT. I find myself puzzled by the various client-side storage options available for storing tokens: Cookies, Session, and JWT/Passport. Is it necessary to store tokens in cookies, ...

The issue persists with the JavaScript window.location script constantly refreshing

I am currently working on a small web application where I want to update 2 parameters in the URL using Javascript. However, every time I use "window.location.search = 'scene.html?name=' + person + '&scene=' + readCookie("scene");", the page just keeps ...

Configuring the session expiration time in Node.js Express by setting it in the SessionStore rather than in a cookie

Every resource I have come across regarding Express Sessions focuses on setting the cookie expiration times. session.cookie.expires = null; // Browser session cookie session.cookie.expires = 7 * 24 * 3600 * 1000; // Week long cookie However, the cookie ...

Obtain the HTTP cookie from the browser

I am using AngularJS and I need to find a way to prevent the default cookie sent from the server, which has an expiration set to session. Alternatively, I would like to extract the authentication value from this cookie and save it to my own custom cookie f ...

Front-end user authentication concerns when employing JWT

Currently, my focus is on transitioning to the MERN stack and incorporating an authentication module using Next.js (front-end) + Node.js (for scalability). I am utilizing JWT token method for authentication and have some concerns: Storing tokens in coo ...

Express JS is not sending cookies during redirection

I have two distinct applications, which I will refer to as Login and Dashboard. Both applications are built with a user interface in react and utilize an express server. When a POST request is made from the Login UI in my Login app, it interacts with the ...

NextJS is encountering an issue with Axios' withCredentials functionality

I'm facing an issue where Axios is not sending the cookie to my backend API, even though I have set the withCredentials properly. Front-end (NextJS): import axios from "axios" const BASE_URL = "http://localhost:8000" export defa ...

Best method for routing all requests to an external API via a Next.js server? (Ensuring seamless integration of SSR components with client authentication cookies)

Running a rails API in the same cluster as my Next.js13 server has posed some challenges. The rails API utilizes auth cookies to track sessions, allowing for authenticated API calls from client-side components based on the received set-cookie header. Howev ...

How can the Domain attribute of the Express.js cookie setter be utilized to share a cookie across multiple domains effectively?

Consider a scenario where you have the cookie setter code as follows: res.cookie('name', 'tobi', { secure: true, httpOnly: false, sameSite: 'None', domain: '.example1.com' }); To make the cookie accessible on multiple domains instead of ...

php The setcookie function is not functioning properly

Here are the contents of my test files: File test.php: <?php setcookie("test", "test", time() + 3600); header("Location:test2.php"); File test2.php: <?php if(!isset($_COOKIE['test'])) { echo 'cookie not set'; } else { ...

Using Jquery and the cookie.split method to extract and eliminate a value from a cookie

I am trying to figure out how to remove a specific matching value from a cookie using JavaScript. I have written a script that loops over the cookie and checks for matches, but I can't seem to successfully remove just the matching value. Any tips on achi ...

Unable to interact with cookies using Python's selenium package

My current project involves using Python, Selenium, and PhantomJS to access a webpage. After getting the page with driver.get and logging in, I received a notification that cookies needed to be enabled. In an attempt to access these cookies, I implemented ...

Is there a way to store a jQuery CSS manipulation within a cookie?

On my Wordpress site, I have a code that allows users to change the font size of the body when they click on one of three generated buttons: <button class='body_standard_font_size'>Standard</button> <button class='body_medium_font_size'> ...

Storing a JSON as a cookie in a Django response

Is there a way to store a dictionary/json object in a client-side cookie from Django and retrieve it as a JavaScript object? response = HttpResponseRedirect(reverse('app:home')) response.set_cookie('cookiekey', 'value') retu ...

Battle of Cookies and User Preferences: Who Will Prevail?

Recently, I encountered a challenge while developing an ecommerce site. After facing numerous issues, I believe I may have finally found a solution. (For more details on the problem and my question, click here) The expected scenario: Users checkout and p ...

Are cookies always included in client requests?

With every interaction between the server and browser, cookies are exchanged back and forth. However, what happens when an image is requested? <img src='myPic.jpg' /> Is the browser also sending cookies during this type of request? If i ...

Heroku failing to set cross-site cookie through the Set-Cookie Response Header

Despite working fine locally, I am facing issues with setting cookies on Heroku when making cross-site calls. This problem seems to be occurring specifically in Chrome and Safari, the two browsers I have tested so far. It could be due to either the cross-s ...

Is there a way to monitor the last five pages accessed using cookies in a PHP environment?

<?php session_start(); if(empty($_SESSION['track'])) $_SESSION['history'] = array($_SERVER['PHP_SELF']); else { $_SESSION['track'][] = $_SERVER['PHP_SELF']; if(count($_SESSION['track']) > 5) array_shift($_SESSION['tr ...

Having trouble setting a cookie. Sharing the complete code on codeSandBox for both backend and frontend. Can anyone spot the issue? Appreciate the help! Using Express with Vue 3

Presenting a sandbox of a backend, featuring a simple setup with one route and one controller. Curious to explore the full code for the backend? Check it out here. As for the frontend, it's equally straightforward. I began by creating a new Vue 3 project ...

What could be the reason for the cookie not being set in the browser's response headers?

At my localhost server, I run the backend on http://localhost:4000 and the frontend on http://localhost:3000. In the Express server, I have set the cors policy as follows: app.use( cors({ credentials: true, origin: "http://localhost:3000&quo ...

Session-based Authorization

I'm completely new to working with express.js, and I've been facing an issue while trying to create a session-cookie after logging in. Even though I can initiate the session and successfully log in, the session data doesn't carry over to the next path. I r ...

PHP Login and Cookies functionality specifically designed for the homepage

I started learning PHP just a week ago, but now I'm facing an issue. My PHP login and session script only work on the front page. When I test it by clearing cookies and typing in the browser to a specific page on my site (for example: www.mysite.com/page34 ...

The combination of a modal box, checkbox, and cookie feature creates

I am trying to accomplish the following tasks: When the homepage loads, I want a modal box to appear Inside the modal box, there should be a form with a mandatory checkbox After checking the checkbox, submit the form and close the modal box to return to ...

The lifespan of my cookie is limited

I am utilizing the jQuery.min.js from https://github.com/carhartl/jquery-cookie and my cookie code looks like this: $(function() { //hide all divs just for the purpose of this example, //you should have the divs hidden with your css //check ...

Session management in Node.JS can be implemented without the use of

Even after multiple attempts, I have discovered that iOS 5 does not accept cookies by default. Despite trying various approaches, including utilizing Redis, I still cannot maintain a session for more than one request. Considering the limitation with cooki ...

What is the proper method for transmitting a token as Bearer authentication in the header to the browser

Here is a snippet of code from my helper signin router where I am attempting to set a cookie in the browser after confirming sign in. exports.signin = (req,res) => { db.User.findOne({email:req.body.email}).then(user => { user.c ...

Is it feasible to alter cookie data within a jQuery ajax call?

I'm currently developing a Chrome extension that enables users to capture all HTTP requests for a specific website, edit components of the request, and then send it again. My plan is to utilize jQuery's ajax function to design and dispatch the a ...

Express 4.13.4 appears to be disregarding the cookie's expiration date when the moment.toDate() function is used

I've been encountering an issue where I am attempting to set a cookie with a specific expiry date of 3 months, but the expiration is not setting correctly. Using momentJS, I created a date object for the desired time. The console confirms that the correct ...

Why Am I Still Getting a 431 (Request Header Fields Too Large) Error in My React App Despite Clearing

Whenever I try to run a post request in my React app, I encounter the "431 (Request Header Fields Too Large)" error and I'm unable to identify the cause. Is there anyone who can assist me with this problem? I've attempted various solutions based on respon ...

Retrieve some delicious cookies by making an AJAX request

I have been attempting to retrieve cookies that were set at the backend following an AJAX post, and despite trying various solutions I have come across, I am still unable to find where I may be going wrong. Below is a code snippet for extracting headers f ...

Setting up cookies and sessions in an Electron application

Creating a cookie/session in my Electron app has been tricky for me. I attempted to use the default document.cookie method, but unfortunately it did not work. I have looked through the Cookie documentation, but have not been able to find information on ho ...

What strategies are most effective for handling sessions in Node.js?

Currently, I am delving into the world of Node.js and I find myself pondering the best approach to handle sessions. Upon my investigation, it appears that there are primarily two options available: express-session and cookie-session. Sources suggest that ...

Is there a way to configure a cookie and then proceed to redirect using the built-in http/https modules?

It seems that all the examples I have found for this issue involve using express. I've attempted various solutions, such as the following: res.writeHead(200, { 'Set-Cookie': cookie, 'Content-Type': 'text/plain' }) res.writeHead(302, {'Location': '/ ...

Troubleshooting the issue of Angular2's http withCredentials not functioning as expected

Utilizing Angular2's HTTP module, I am sending HTTP requests. Once a user logs in, the backend server creates a cookie session which is then used by the frontend to send subsequent requests. The Angular code snippet is outlined below: get(url: string ...

Header Express does not contain any cookies, which may vary based on the specific path

In my express.js app, I have two controllers set up for handling requests: /auth and /posts. I've implemented token authorization to set the Authorization cookie, but I'm encountering an issue when making a request to /posts. The request goes th ...

Building a customised-schema table for storing data with express-mysql-session

I am exploring the option to store the user id in the MySQL Database's sessions table using express-mysql-session. Initially, I set the user id in the middleware as shown below: import "dotenv/config"; import express from "express" ...

Tips for minimizing API calls when validating the authenticity of a JWT token stored in a cookie

Upon a user logging in through my React frontend, an API call is made to the server side to generate a JWT token which is then sent back in a secure HTTP-only cookie. Subsequent API calls from the frontend include this cookie for verification on the server ...

What is the syntax for utilizing cookies within the `getServerSideProps` function in Next.js?

I am struggling to pass the current language to an endpoint. Despite attempting to retrieve the language from a Cookie, I keep getting undefined within the getServerSideProps function. export async function getServerSideProps(context) { const lang = aw ...

Vue cookies experiencing issues with updating cookie values correctly

My goal is to store user preferences (maximum 2-3 users) in a cookie for easy access. Upon login, I first check if the 'users' cookie exists. If not, I create it. If it does exist, I check if the current user is included in the cookie. If not, I ...

The absence of authentication field in the headers results in an error when trying to store a

I am attempting to log in using a Cookie JWT HTTPOnly, but I am facing an issue where the cookie coming with the server response is labeled 'cookie'. However, I would prefer it to be in a field named 'authorization' with a 'Bearer' token type. Currently, I ...

What is the best way to retrieve a cookie sent from the server on a subdomain's domain within the client request headers using getServerSideProps

Currently, I have an express application using express-session running on my server hosted at api.example.com, along with a NextJS application hosted at example.com. While everything functions smoothly locally with the server setting a cookie that can be r ...

Issue with setting cookie in Codeception and Selenium

My Selenium test is failing when trying to set a cookie, despite reducing the code to its simplest form. It seems that setting cookies is not working at all in this case. /** * Test if we can set simple cookies * * @param \AcceptanceTester $i * ...

Is it possible to implement sanctum on multiple Vue projects simultaneously?

Greetings! I am currently using Sanctum to authenticate users in the system. My goal is for a user who logs in to vue project num1 to also be automatically logged in to vue project num2. I attempted to implement this functionality using cookies like so: $ ...

Do session secrets in Node.js serve the same purpose as signed cookies?

Setting up sessions in Express is done like this: app.use(express.session({ store: store({...}), secret: 'topsecret' })); I recently learned that the secret parameter protects against session hijacking by verifying the fingerprint. This functionalit ...

The issue with NextJs middleware is that it is unable to access the cookie immediately after setting it. A page reload is

Once the cookie is set, I am unable to retrieve it in the middleware without having to refresh the page first. Why does this occur? The cookie is being set as shown below: import { getCookies, setCookie, deleteCookie, hasCookie } from 'cookies-next&a ...

Establishing global credentials in VueJS using Axios

When working in main.js, I included the following code: axios.defaults.withCredentials = true; Although this should make it work, I found that the cookies were not being sent to the back end. I inspected the request header and noticed something strange: ...

How to identify cookies in php using the session_start() function

I have been researching how to determine if a user has blocked cookies using PHP. While looking for solutions online, I found recommendations to create a cookie, redirect to another page, and then check the cookie. However, I also came across an alternativ ...

HttpOnly Cookies are not received by the Chrome Node in Selenium Hub as expected

My Selenium tests are set up in two different ways: Running locally with Chrome WebDriver to create and implement the tests Executing them in a CI pipeline using Selenium Hub and a Chrome Node The backend of the application creates HttpOnly cookies, and ...

Encountering difficulties setting cookies within the app router in Next.js

I've been diving into next.js and I'm trying to figure out how to set a cookie using the code below. However, I'm encountering an error: "Unhandled Runtime Error. Error: Cookies can only be modified in a Server Action or Route Handler." I was under the i ...

Angular developers may encounter a dependency conflict while attempting to install ngx-cookie

I'm currently facing an issue while attempting to add the ngx-cookie package for utilizing the CookieService in my application. Unfortunately, I am encountering some dependency conflicts that look like the following: $ npm install ngx-cookie --save np ...

Retrieve Cookie from a designated domain using Express

I am currently working on a React application that communicates with a Node/Express backend. To ensure the validity of requests, I am sending a cookie created by react-cookie from the React app to the Express app. To avoid issues related to naming conflict ...

Issue with Express-session: Cookie expiration not being reset with every request

I'm currently utilizing express-session for authentication in my web application. Unfortunately, I've encountered a persistent problem where the cookie expiration time isn't being reset with each request. Here's the code snippet that I'm working with: mai ...

React's Google Login component is encountering a cookiePolicy error that is deemed invalid

Currently, I am developing a basic website using React and experimenting with the GoogleLogin component found at https://www.npmjs.com/package/react-google-login. My React server is running on http://localhost:3000 and I have configured the cookie-policy t ...

What is the reason browsers do not store JWT tokens in the same manner as they do cookies?

Understanding the distinctions between a cookie and a JSON web token is crucial. With cookies, when the server includes 'set-cookie' in its response header, the browser automatically stores the cookie in local storage. Then, whenever the cookie i ...

PHP variables are unable to fetch HTML option values in real time

Let's create a website with a product addition feature using PHP code. For instance, we can add a phone as a product where the category is Mobile Phones and the subcategories could be Samsung or iPhone. Another example could be adding Cars with options for ...

How to dynamically alter a PHP variable using a JavaScript button click on the existing webpage

I've spent the last hour scouring stackoverflow for answers to my problem, but trying out solutions has only resulted in errors - perhaps because I'm attempting to implement it on the same page. I've experimented with saving the value to a cookie in JavaS ...

Stylish popup image with a link to an external source

Currently, I am utilizing Fancybox 3 and Cookie in order to display hidden content once the page has finished loading. The concealed content consists of both an image and an external link. I am encountering difficulties with regards to the functionality ...

Are cookie-session and JWT tokens essentially the same thing in Express, or is there a difference between them?

When looking at the express documentation, you will come across a differentiation between express-session and cookie-session. The explanation provided is as follows: There are two main ways to store a user session with cookies: either on the server or on ...

Can I retrieve cookies and dynamically render a JSX component depending on a specific condition?

I have implemented the 'react-cookie' package in my project: https://www.npmjs.com/package/react-cookie Based on this documentation, I've created JSX components that function to create a cookie named 'cookieConsent' and set its ...

13 upcoming issues with server components related to cookies

My code involves retrieving cookies from the user on the front end, verifying it against a backend token stored in a database, and controlling access to certain pages based on this validation. If the "token" cookie is present, the user is allowed access, o ...

Unable to send multiple cookies using custom headers in Next.js configuration

I am using custom headers to set the cookie in my next.config.js file. The refresh token is successfully set, but for some reason the second token is not being recognized. key: 'Set-Cookie', value: `RefreshTokenKey = " ...

Once the Ajax request is finished, the cookie deletion function ceases to function

When the website loads, a cookie is generated using PHP before any other content or headers are sent. This is done with the following code: $steam_login_verify = SteamSignIn::validate(); if(isset($_COOKIE['userid'])) { //work with cookie va ...

Tips for changing a cookie in php

I am looking to save a specific format string in a cookie: 1.236|2.48|3.574|4.094| Each number from 1-4 corresponds to a div, and the number after the dot represents a property of that div. The task is for PHP to check the cookie, and if there is an en ...

Is there a method to manually generate a cookie for Internet Explorer using InnoSetup?

Is there a way to manually create a cookie in InnoSetup on behalf of a specific website, such as www.stackoverflow.com, similar to how JavaScript cookies are stored? Javascript cookie: function setCookie(cname,cvalue,exdays) { var d = new Date(); d.s ...

Creating a multilingual website using PHP, MySQL, and cookies

Having developed a multilingual website using PHP and MySQL, I am currently facing issues related to robots, SEO, and search engines. This is mainly due to the fact that the language selection mechanism relies on cookies. The current process is as follows ...

Comparing SSR and CSR Approaches to Handling getInitialProps in _app.js with Next JS

I am currently working on developing a Next JS application that manages authentication and initial routing within the getInitialProps function. I have found that this method can be executed either server-side or client-side. My current approach involves ...

Automating the process of updating cookies with Selenium and Python

I've been experimenting with checking the freshness of my cookies. Specifically, I'm conducting tests on Facebook.com. It's a hassle to have to log in every time I want to test something, so I'm keen on avoiding that if possible. Howev ...

The HttpOnly cookie is visible in the response header, however, it is not being stored in the browser

I recently created a straightforward real-time chat application using Nextjs for the front end and Express for the back end. The front end is hosted on Vercel, while the back end is hosted on Heroku. When a user logs in to the app, the back end generates a ...

Is the javascript function I created not recognized as "a function"?

A small .js file containing 3 functions for easy in-site cookie management was created. Below is the source code: // Create Cookie function Bake(name,value) { var oDate = new Date(); oDate.setYear(oDate.getFullYear()+1); var oCookie = encodeURIComponent(n ...

Failure to set X-XSRF-TOKEN header in Angular5

After exploring several solutions, I have yet to find one that works for me. This issue on Github closely mirrors my problem (https://github.com/angular/angular/issues/20511) My setup includes Angular 5.2.5, Chrome Version 65.0.3325.146, and Spring Boot ...

What is the best time to inquire about the client's currency preference in the absence of a country code in the `accept-language`

Explaining the Functionality: Identifying Client Currency To determine the client's preferred currency, I extract their locale information from the accept-language header. By analyzing the language and country codes within the accept-language header, ...

How can I execute Java Selenium tests on Chrome while blocking third-party cookies?

I am aiming to modify some java selenium tests so that they run on Chrome with third party cookies blocked. Is there a way to achieve this? Are there any successful examples available demonstrating how to accomplish this task? I have come across suggestio ...

How can I use cookies to make an HTML div disappear when a button is clicked?

I've been attempting to conceal this message in Vue.js, but so far I haven't had any luck. Currently, I am utilizing the js-cookie library. My objective is as follows: HTML <div v-show="closeBox()"> < ...