What could be causing Safari to overlook my session and remember-me cookies?

Some users of my web application have been encountering frequent login issues, ranging from every few hours to every few days. Interestingly, these problems seem to be specific to Safari users. It appears that Safari is affecting the session cookies and remember-me cookies in a strange way.

These users do not face similar difficulties on other websites, and this issue seems to have arisen only recently, despite no updates being made on my end. I suspect that a Safari update may have altered its behavior, but since I do not have access to Safari for testing, it poses a challenge to troubleshoot.

The server uses node/express, with the relevant code as follows:


app.use(session({ // uses cookie connect.sid
  secret: process.env.SESSION_STORE_SECRET,
  store: mongoStore,
  maxAge: new Date(Date.now() + 3600000),
  resave: false,
  saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())
app.use(passport.authenticate('remember-me'))

Upon reviewing the code, I realized that the 'maxAge' parameter might be causing the problem. It seems that Safari may handle 'session' cookies differently than the 'remember-me' system. Other browsers appear to work fine with the latter, hence why the issue went unnoticed by me.

I am considering removing the 'maxAge' line, as the default setting does not include one and seems to function properly.

Feel free to visit the site if you want to inspect the cookies and related elements.

Answer №1

Perhaps the maxAge parameter is causing the issue here. It could be that Safari handles session cookies fine but has some strange behavior with the remember-me system, unlike other browsers which seem to work without any problems. This may have gone unnoticed as I personally do not use Safari.

I have decided to delete the line containing the maxAge parameter, as the default setting does not include one and everything seems to be working smoothly without it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Altering the hue of various stroke patterns

I've encountered an issue where I want to create skill bars that display my skills in percentages. Luckily, I found a great code that allows me to do this. Although I would prefer to do it myself, I haven't come across a good tutorial that teache ...

difficulty encountered when using the Angular delete method in conjunction with Express.js

I am trying to send a delete request to my Express server from Angular. remove: function (id) { return $http({ method: 'DELETE', url: '/users/delete/'+ id }) } In my Expr ...

Retrieving Data from all Rows in jQuery DataTables

Is there a way to copy all rows in jQuery DataTables into a JavaScript array by clicking the header checkbox? https://i.sstatic.net/57dTB.png I need to locate where jQuery DataTables store the HTML for the remaining page of rows so that I can manipulate ...

Is it necessary to encapsulate the last Typsecript export in a module?

I am facing the challenge of exporting multiple models and services within a TypeScript module. Origin models/User.ts import {IModel} from "./IModel"; export interface User extends IModel { // ... } services/UserService.ts import {inject} from & ...

using jQuery to eliminate an HTML element based on its attribute

How can I remove an element with the attribute cursor = "pointer"? I want to achieve this using JavaScript in HTML. Specifically, I am looking to remove the following item: <g cursor="pointer"></g>. It's unclear to me why this element has ...

Show a dynamic Swiper carousel upon selecting a thumbnail in an image gallery

I am in the process of creating a thumbnail gallery that includes a slider feature using Swiper. The default setup has the slider hidden, and once an image is clicked, the slider should appear with the selected image. To close the slider and return to the ...

Error encountered while deploying React app on Netlify due to absence of build scripts

I recently deployed a React app on Netlify from GitHub. Unfortunately, the deployment status showed as failed with the following error: Mar 27: Failed during the stage of 'building site': Build script returned a non-zero exit code: 1 I als ...

What is the best way to calculate the total sum of grouped data using mongoose?

I have a collection of log data that I need to work with. [ { "logType":1, "created_at": 2015-12-15 07:38:54.766Z }, .. .. .., { "logType":2, "created_at": 2015-13-15 07:38:54.766Z } ] My task is to group the ...

Display the component only if the image source is legitimate

Before rendering an Image component, I want to ensure that the URL is valid and not broken. My current approach seems error-free and the onload function is functioning properly. However, I suspect there might be an issue with how I am handling the return ...

Updating JSON values based on a list of keys in JavaScript

I possess an item that delves deep into its structure. For instance: section: { data: { x = 4 } } The actual one goes even deeper. How do I go about updating the x value with a function like this: const keys = [section, data, x]; cons ...

Mat-SideNav in Angular Material is not toggled by default

<mat-toolbar color="primary"> <mat-toolbar-row> <button mat-icon-button> <mat-icon (click)="sidenav.toggle()">menu</mat-icon> </button> <h1>{{applicationN ...

Loading files using $scriptjs or any other asynchronous loader allows for seamless integration of external resources

Imagine I have developed an AngularJS application that lazy loads controller files (using $scriptjs) and all dependencies when the user navigates to a specific route. This application consists of 3 routes: A, B, and C. My question is: if the user navigate ...

Issues with integrating chart.js in Laravel 7: Element #app not found?

Currently, I am utilizing chart.js to display the statistics of reviews and messages for a user. However, I have encountered issues with the scripts. While the stats are functioning correctly, an error message stating Cannot find element: #app is appearing ...

Retrieving information from an API and transferring it to the state in a React component

I am currently working on a random quote generator project, and I'm facing some difficulties in passing the API data to my state and also accessing it in the QuoteComponent through props. Despite following all the correct procedures, whenever I try to ...

Enhance your website with a dynamic jQuery gallery featuring stunning zoom-in

I am currently working on a mobile website project and I'm in need of a gallery feature that allows users to zoom in on images and swipe through them using touch gestures. After some research, I haven't been able to find a suitable solution in j ...

What causes the appearance of 'GET/ 304 --' in my code? (vue.js, express)

While attempting to fetch data on the client-side using axios in vue.js, I encountered a server-side error with the code 'GET/ 304 --' The reason for this occurrence is unclear to me and I am unsure of how to troubleshoot or resolve it. If I re ...

Encounter an Internal Server Error while using Laravel 5.4

I am encountering an issue while attempting to implement ajax search in my laravel project. I have included the controller and JavaScript code related to this problem below. Can you please take a look and let me know what may be causing the error? pu ...

A Python program that creates an HTML webpage

I am currently working on a Python script that, when launched on localhost with Apache, will generate an HTML page. Here is the script (test.py): #!/usr/bin/python # -*- coding: utf-8 -*- import cgitb cgitb.enable() import cgi form = cgi.FieldStorage() ...

React and Express working seamlessly together on separate localhost ports without CORS interfering with the fetch call

I'm puzzled by why CORS isn't blocking the Axios get request. Here are the specifics: React running on: localhost:3000 Express running on: localhost:3001 Express code snippet: const express = require('express'); const app = express ...

Tips on utilizing variables instead of static values when calling objects in JavaScript

How can I make something like this work? I tried putting the variable in [], but it didn't work. Can someone please help me out with this? Thank you. const obj = { car : "a" , bus: "b" }; const x = "car" ; ...