Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandyczech's avatar

Session doesnt work in FIREFOX

Laravel does not save a session in Firefox browser (59.0.2). Chrome is OK ....

0 likes
20 replies
jcmargentina's avatar

Do you allow cookies ? check your broswer preferences

Also ... do you have firebug extension installed ? well, ... it may cause troubles too.

vandyczech's avatar

Cookies arent blocked ... browser is in default state. ... No i have not Firebug

vandyczech's avatar

chrome return for session right, but firefox return null

vandyczech's avatar

my token session miss ...

chrome

array:4 [▼
"_token" => "IdiLK5yJXZRJvcVHJwmlNRmDkqn0Ub9ixa2J2Z66"
"_previous" => array:1 [▶]
"_flash" => array:2 [▶]
"token" => "f81wv75183355"

]

firefox

array:3 [▼
"_token" => "mvDqAxwP1jE5n2WUuiX8i9TikG5FuiFcjYVweHng"
"_previous" => array:1 [▶]
"_flash" => array:2 [▶]

]

jcmargentina's avatar

Open an anonymous navigation TAB in firefox, and check again there. Let me know

jlrdw's avatar

Session and cookie is two different things.

Edit just tested session on FF 59.0.2 (64-bit), no problems.

Cronix's avatar

I use firefox as my main browser now for about the last 6 months and have never had a session issue with laravel 5.3 - 5.6. There is a plugin or browser setting (that's not default) or something strange doing this.

Helmchen's avatar

Session and cookie is two different things.

Not necessarily. session_use_trans_sid is disabled per default and there really is absolutely no reason to use it anyway. The plain old PHP session (id) is always stored inside cookies, although session cookies and other (third party) cookies may have different security settings in the browser.

If cookies are blocked, your fu**** - unless you use technics like Web Tokens or API Keys, which are passed through HTTP Headers with every single request.

or did i miss something?

@vandyczech

so, is the session not working (no session created at all) or is it just the data that get's not persisted like you expected? cause THAT are really 2 different things.

jlrdw's avatar

A session is stored on server a cookie is stored in browser like comparing apples and oranges.

vandyczech's avatar

I try describe my problem,

For each user which visit the web in url /calculation i want generate token like f87ru42946721 and store the token persistence to the moment when user close the browser or remove history and cookies for example .... I need store the same value of the token through the each request, not only for next ... for each what i want ... something:

   session()->keep()
Cronix's avatar
Cronix
Best Answer
Level 67

user close the browser or remove history and cookies

Then you'd want to use the HTML5 Web Storage API to store the data. If the user deletes cookies, and they delete the session cookie (with the ID to their session), then you will lose all session data for them (and they'll get logged out too). So the only way to store it permanently is in the users browser using local storage.

Of course, they can delete that too in the browser dev tools or via javascript.

https://www.w3schools.com/html/html5_webstorage.asp

localStorage.setItem("token", "f87ru42946721");

let token = localStorage.getItem("token"); // f87ru42946721
1 like
vandyczech's avatar

It sounds good ... But how make this in Laravel 5.6?

Helmchen's avatar

@jlrdw Now you are picky. Your session datais worthless without a way to identify the user. How do we identify them? session_id, where is it stored? cookie.

session_id (cookie) + session_data (server) = Session. You can turn it like you want, without cookies it's just not working, unless you have a very specific reason and implementation to work around that. The SID parameter in PHP4 was one of them.

Sometimes you have to look at the whole thing and not just talk about terms. That's just annoying.

Cronix's avatar

Then you have basically just eliminated all of your options, given your requirements.

store the token persistence to the moment when user close the browser or remove history and cookies for example

i dont want depend on javascript

You can only detect when the user closes the browser by javascript via the window.onunload event. If they remove the cookie, you lose your session data in php. Using the HTML5 storage engine uses javascript.

Not sure what else you could really do.

Helmchen's avatar

if you are talking about authenticated users, you may also persist the data in the database or wherever you like. Just use the user_id as reference, rather then the session_id. If you save them on every request, you don't really have to check for such things like closing the browser or deleting the session cookies, it's available as long as you store it.

Please or to participate in this conversation.