Questions tagged [cookies]

An HTTP cookie is a piece of data stored by the user's web browser. Unless otherwise specified, cookies can be created, read, modified and deleted both by JavaScript and from server-side through HTTP headers.

cookies
Filter by
Sorted by
Tagged with
309 votes
3 answers
214k views

How does cookie-based authentication work?

What would be a step-by-step description of how cookie-based authentication work? I've never done anything involving either authentication or cookies. What does the browser need to do? What does the ...
Mastid's user avatar
  • 3,269
157 votes
9 answers
148k views

Differences between cookies and sessions?

I am training in web developement and am learning about JSP & Servlets. I have some knowledge of HttpSession - I have used it in some of my sample projects. In browsers I have seen the option to "...
blacktiger's user avatar
  • 19.1k
123 votes
3 answers
146k views

How to expire a cookie in 30 minutes using jQuery?

How to Expire a Cookie in 30 min ? I am using a jQuery cookie. I am able to do something like this. $.cookie("example", "foo", { expires: 1 }); This is for 1 day. But how can we set expiry time to ...
bluwater2001's user avatar
  • 7,899
100 votes
12 answers
193k views

Destroy cookie NodeJs

I am using Cookies module for setting cookie. Here is following my code: var options = { maxAge: ALMOST_ONE_HOUR_MS, domain: '.test.com', expires: new Date(Date.now() + ALMOST_ONE_HOUR_MS)...
Manwal's user avatar
  • 23.6k
92 votes
7 answers
260k views

jQuery $.cookie is not a function

I am trying to set a cookie using jQuery: $.cookie("testCookie", "hello"); alert($.cookie("testCookie")); But when I load my page, I receive the error "$.cookie is not a function". Here is what I ...
ElliotSchmelliot's user avatar
89 votes
3 answers
77k views

Set start date and expiration date for Rails cookies

How do I set a Rails cookie to start and/or expire at a certain date?
user avatar
84 votes
9 answers
295k views

Where does Chrome store cookies?

Let's say I set a cookie using the setcookie() function in PHP: setcookie('name','foo',false,'/',false); I can see it in: chrome://settings/cookies However, I can not find the actual file stored ...
Kobayashi's user avatar
  • 2,482
79 votes
6 answers
129k views

How can I create persistent cookies in ASP.NET?

I am creating cookies with following lines: HttpCookie userid = new HttpCookie("userid", objUser.id.ToString()); userid.Expires.AddYears(1); Response.Cookies.Add(userid); Now how can I make ...
Vikas's user avatar
  • 24.2k
77 votes
10 answers
193k views

How do you configure HttpOnly cookies in tomcat / java webapps?

After reading Jeff's blog post on Protecting Your Cookies: HttpOnly. I'd like to implement HttpOnly cookies in my web application. How do you tell tomcat to use http only cookies for sessions?
ScArcher2's user avatar
  • 86.6k
69 votes
7 answers
133k views

How to Delete Session Cookie?

How to dynamically, via jQuey, delete a session cookie, without manually restarting the browser? I read somewhere that session cookie is retained in browser memory and will be removed when the browser ...
Nordin's user avatar
  • 3,177
68 votes
7 answers
166k views

How to get cookie expiration date / creation date from javascript? [duplicate]

Is it possible to retrieve the creation or expiration date of an existing cookie from javascript? If so how?
Nir's user avatar
  • 25k
61 votes
20 answers
128k views

Express doesn't set a cookie

I have problem with setting a cookies via express. I'm using Este.js dev stack and I try to set a cookie in API auth /login route. Here is the code that I use in /api/v1/auth/login route res.cookie('...
Mira's user avatar
  • 621
51 votes
8 answers
77k views

Preventing CSRF with the same-site cookie attribute

I was surfing the web and found article Preventing CSRF with the same-site cookie attribute. As on link maintain We need to add Set-Cookie header. Set-Cookie: key=value; HttpOnly; SameSite=strict ...
imlim's user avatar
  • 1,637
46 votes
9 answers
72k views

What is the maximum size of a cookie, and how many can be stored in a browser for each web site?

I am learning about cookies, and I wonder about browser support when writing web applications that rely on cookies to store state. For each domain/web site, how many cookies may be sent to a browser, ...
giri's user avatar
  • 27k
42 votes
10 answers
63k views

OWIN - Authentication.SignOut() doesn't seem to remove the cookie

I'm having some issues with OWIN Cookie authentication. I have a .Net site that has some MVC pages which uses cookie authentication and WebAPI resources protected by a bearer token. When I log out, I ...
jaeyow's user avatar
  • 469
8 votes
2 answers
23k views

How to do htaccess redirect based on cookie value

I have failed at Google and I could not find the answer searching here. Sorry, I'm a newb at htaccess and it has really odd syntax and is so hard to learn! You can see what I'm trying to do here... ...
BinaryGal's user avatar
6 votes
2 answers
17k views

How can I scrape website content in PHP from a website that requires a cookie login?

My problem is that it doesn't just require a basic cookie, but rather asks for a session cookie, and for randomly generated IDs. I think this means I need to use a web browser emulator with a cookie ...
Forest's user avatar
  • 938
316 votes
4 answers
299k views

How are cookies passed in the HTTP protocol?

How are cookies passed in the HTTP protocol?
jai's user avatar
  • 21.7k
116 votes
7 answers
69k views

How to expire session due to inactivity in Django?

Our Django application has the following session management requirements. Sessions expire when the user closes the browser. Sessions expire after a period of inactivity. Detect when a session expires ...
Akbar ibrahim's user avatar
114 votes
2 answers
110k views

How does cookie "Secure" flag work?

I know that a cookie with secure flag won't be sent via an unencrypted connection. I wonder how this works in-depth. Who is responsible for determining whether the cookie will be sent or not?
ted's user avatar
  • 5,259
84 votes
5 answers
254k views

Does Axios support Set-Cookie? Is it possible to authenticate through Axios HTTP request?

I'm trying to authenticate express API back-end using Axios HTTP request call. I was able to see 'Set-Cookie' in the response header, but cookie was not set. Is it possible to set cookies through ...
Mandakh's user avatar
  • 1,143
82 votes
18 answers
44k views

Why are cookies unrecognized when a link is clicked from an external source (i.e. Excel, Word, etc...)

I noticed that when a link is clicked externally from the web browser, such as from Excel or Word, that my session cookie is initially unrecognized, even if the link opens up in a new tab of the same ...
Nick's user avatar
  • 1,059
75 votes
6 answers
103k views

Why is the browser not setting cookies after an AJAX request returns?

I am making an ajax request using $.ajax. The response has the Set-Cookie header set (I've verified this in the Chrome dev tools). However, the browser does not set the cookie after receiving the ...
Matt Fichman's user avatar
  • 5,576
72 votes
6 answers
223k views

How to fix "set SameSite cookie to none" warning?

I created a chrome extension and from popup.js I called PHP script (Using Xhttprequest) that reads the cookie. Like this: $cookie_name = "mycookie"; if(isset($_COOKIE[$cookie_name])) { echo $...
Danilo Ivanovic's user avatar
70 votes
1 answer
45k views

Reading cookies via HTTPS that were set using HTTP

Can cookies set using HTTP be read using HTTPS?
Daniel Schaffer's user avatar
65 votes
5 answers
29k views

What does Rails 3 session_store domain :all really do?

Updated question to make it more clear I understand that you can set the domain of your session_store to share sessions between subdomains like this: Rails.application.config.session_store :...
Nader's user avatar
  • 5,563
63 votes
5 answers
70k views

How to manually decrypt an ASP.NET Core Authentication cookie?

Let's consider a common-known ASP.NET Core scenario. Firstly we add the middleware: public void Configure(IApplicationBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions() ...
Ilya Chumakov's user avatar
60 votes
4 answers
85k views

I want to store Javascript array as a Cookie

Is it possible, I have a some sort of list and I want to store it on browser, if it is not possible, what is the efficient way of doing this?
Oguz Bilgic's user avatar
  • 3,432
53 votes
1 answer
50k views

Why can't I set a cookie and redirect?

I'm having a problem setting a cookie and doing a 302 redirect In chrome the cookie is not being set (I haven't tested safari), in other browsers I was having the same problem until I added Path=/ to ...
Damian's user avatar
  • 5,531
51 votes
9 answers
52k views

PHP Sessions with disabled cookies, does it work?

Today I had skype interview for a job as PHP developer, one of the questions asked was about Cookies and PHP Sessions. The question was, can PHP session be set and read, used, if Cookies are disabled ...
Limeni's user avatar
  • 5,084
49 votes
6 answers
71k views

How can I set a cookie and then redirect in PHP?

After doing a bit of processing, I want to set a cookie value to user input and then redirect them to a new page. However, the cookie is not getting set. If I comment out the redirect, then the ...
Wickethewok's user avatar
  • 6,604
48 votes
3 answers
46k views

Set-Cookie on Browser with Ajax Request via CORS

Attempting to implement an ajax login / signup process (no refresh site with authentication). Using cookies for preserving state. I thought I'd have this right by now but for some reason browser ...
Calvin Froedge's user avatar
47 votes
4 answers
53k views

Check if httponly cookie exists in Javascript

As the question says can you find out if a cookie exists within Javascript if it is a HttpOnly? I don't need to access the information inside of it, just know it has one. A little more information on ...
Grofit's user avatar
  • 18k
47 votes
5 answers
60k views

How do I access HttpContext in Server-side Blazor?

I need to access HttpContext in a page (.cshtml) and in particular a request and then a cookie. Despite available, HttpContextAccessor always has a null value stored in its HttpContext property. ...
Alexander Christov's user avatar
47 votes
5 answers
114k views

Pure Javascript - store object in cookie

No jQuery. I want to store an object or array in a cookie. The object should be usable after page refresh. How do I do that with pure JavaScript? I read many posts, but do not know how to ...
Shlomo's user avatar
  • 3,940
45 votes
10 answers
85k views

Stop people having my website loaded on multiple tabs

I want users to browse my site from only one tab in their browser. How can this be done? Would I use javascript and cookies? For example, I have a website: www.example.com - and I want my clients to ...
Jason's user avatar
  • 496
43 votes
4 answers
56k views

Can two different browser share one cookie?

My requirement is pretty interesting, I want to maintain one cookie between two different browser for same domain. so lets say I have create one cookie with name "mydata" and value "hiscal" from IE, ...
Hiscal's user avatar
  • 641
42 votes
7 answers
42k views

How cookies work?

I wanted to know the interactions of a browser (i.e. Firefox ) and a website. When I submit my user name and password to the login form, what happens? I think that website sends me some cookies and ...
Alireza's user avatar
  • 5,583
32 votes
5 answers
52k views

Why Doesn't Closing A Tab Delete A Session Cookie?

I'm using session-based cookies with my website. To my complete surprise, I noticed if I set a session cookie (not a persistent cookie), close a tab, and then reconnect to the site, the session ...
user avatar
32 votes
4 answers
36k views

Why do cookie values with whitespace arrive at the client side with quotes?

I'm a .NET developer starting to dabble in Java. In .NET, I can set the value of a cookie to a string with white space in it: new HttpCookie("myCookieName", "my value") - and when I read that value ...
user avatar
29 votes
10 answers
57k views

Same-Site flag for session cookie in Spring Security

Is it possible to set Same-site Cookie flag in Spring Security? And if not, is it on a roadmap to add support, please? There is already support in some browsers (i.e. Chrome).
Tomáš Hála's user avatar
27 votes
5 answers
40k views

Using cookies.txt file with Python Requests

I'm trying to access an authenticated site using a cookies.txt file (generated with a Chrome extension) with Python Requests: import requests, cookielib cj = cookielib.MozillaCookieJar('cookies.txt')...
cjauvin's user avatar
  • 3,563
26 votes
3 answers
89k views

How can I set, get and destroy cookies in WordPress?

How can I set, get and destroy cookies in WordPress? I surfed the web but I can't get clear ideas, please help me find how.
Ravichandran Jothi's user avatar
26 votes
2 answers
43k views

Passing cookies while logging in

I would like to integrate python Selenium and Requests modules to authenticate on a website. I am using the following code: import requests from selenium import webdriver driver = webdriver.Firefox() ...
AntoG's user avatar
  • 843
22 votes
3 answers
9k views

question on GWT, Cookies and webpage directing

i am using gwt to create a website. this question is regarding a login page and cookies to save login details. GWT allows you to create a website within a single webpage. my application runs on one ...
molleman's user avatar
  • 2,936
20 votes
5 answers
30k views

Laravel Session always changes every refresh / request in Laravel 5.4

So the title basically says it all, I am using Laravel 5.4, PHP 7.1 and on my local machine sessions are working just fine. Essentially when trying to login or reloading the page every time I get a ...
CMOS's user avatar
  • 2,837
20 votes
3 answers
87k views

How to destroy the session cookie correctly with PHP?

I'm trying to correctly log out of an admin user. Here is my function: function logout() { $_SESSION = array(); //destroy all of the session variables if (ini_get("session.use_cookies")) { ...
Tony Stark's user avatar
3 votes
2 answers
3k views

The notorious yet unaswered issue of downloading a file when windows security is required

There is a web site: http://site.domain.com which prompts for credentials with "windows security" dialog box. So I managed to use WebBrowser control to navigate to the page and send keystrokes to ...
Maju's user avatar
  • 99
2 votes
2 answers
1k views

How to handle the popup "Accepting all cookies" when the element is data-testid - Using Selenium in Python

So I've started a new project to help out a medium bussiness about solar-pannels that I work of ... Basically I want to take data from a specific websites with selenium and see it on my GUI that ...
Thomas's user avatar
  • 37
159 votes
4 answers
134k views

Should JWT be stored in localStorage or cookie? [duplicate]

For the purpose of securing REST API using JWT, according to some materials (like this guide and this question), the JWT can be stored in either localStorage or Cookies. Based on my understanding: ...
pkid169's user avatar
  • 2,320

1 2 3
4
5
76