Frappe.session.user returns wrong user account in portal pages

we were using frappe and ERPNext for the last six months. It was working perfectly AWS EC2 instance but after we try to setup production version in another instance it started acting weird. we have created custom app that uses our own template for our company specific business logic and was working perfectly in the development server. the problem is when user login to their portal page, because frappe.session.user not working correctly they see other users information in some routes(pages).

all our pages are in “www” folder and template files are in “templates” folder.

if we restart supervisor, it will work fine for the first logged in user. but for the next users it will show first logged in user information for some routes.

we used
" /api/method/login " for login and
" /api/method/logout " for logout

even we try to remove all the content from the *.py files, use the default frappe’s portal pages template but it didn’t help.

we have different users that will see different pages based on their role.

frappe.session.user
frappe.get_fullname()

are returning wrong user information.

does anybody has suggestion? It’s urgent we are stuck at the final release for the last two weeks.

1 Like

we finally found out

no_cache = 1 is required in every .py file in the www folder of our custom app.

and run

bench clear-cache

It’s weird it was working fine in development server without above fixes.

2 Likes

Is this the actual must-use solution? Because it only happens on sites that has production mode on, so I’m curious if there is any settings that we should have modified in order to fix the problem instead of having to add no_cache = 1 in all .py code

p.s. the suggested solution did not work for me

Not sure the problem might be the same, but thought it was worth mentioning;

I have a similar issue occurring where Users who login will randomly be assigned the session of a different User. It’s mind boggling because it is impossible to replicate, as it really seems to occur randomly.

We are using SSO with Azure. We have Helpdesk, Wiki and Insights modules installed besides the base Frappe Framework.

This is very concerning to me. We are just about to role out ERPNext in our company. What version are you running?

Have others who have instances with many users had this happen?

@fiveoaks this is quite rare, i dont think this should be of concern for you unless you’re having the issue.

in my experience, this is not the type of issue you have to wonder if you have, you will know it without a doubt because it’ll be annoyingly in your face.

@PedroJACorreia & @Nebiye_Lioul pls mention what kind of hosting you have used and whether you’re using something unusual on the network, like a proxy or vpn.

fyi, i had the same issue and didnt find the cause. it resolved after moving off our LAN server / proxy. I’ve since used 100’s of setups, including some with LANs and VPNs without reproducing the issue.

I’m just getting ready to roll out at our company so not in the position to say whether it is or isn’t a problem for me. I’m probably jumping the gun a little but wouldn’t be a good start if this happens.

How is authentication and sessions handled in Frappe? Is it stateless and solely using a cookie such as a JWT?

@adam26d the instance was v13 and hosted in AWS ec2.