How to set key:values (Some user specific values), After successful logged in

Hello,

Is there any way to set some key:values (Some user specific values) After successful logged in, and access it throughout the Application?

So don’t need to call API again and again.

We have a custom App, and want to do that.

Thanks!

Can try

boot_session = "erpnext.startup.boot.boot_session"

https://frappe.io/docs/user/en/guides/basics/hooks

1 Like

@hetal1110
Can u explain and give example about what do you need to do?

Regards
Bilal

@bghayad,

After successful log in, I want to set some user specific values in Global Variables…that I can use in any doctype throughout the App.

We are using custom App, and have linked user with Department in custom doctype.

Sorry I do not have idea about this :slight_smile:
Where are the global variables? It is just a question because need to know it.

Regards
Bilal

Thanks…From here, I can set values in frappe.boot…

How to set values in frappe.session?

In boot_session set the value using set_user_default(“key1”, “2value2”) and later access it using get_user_default(“key1”)

1 Like

You can add new file boot.py in your app directory. Then add following code in it

from __future__ import unicode_literals
import frappe
from frappe.utils import cint

def boot_session(bootinfo):
bootinfo.user_tasks = frappe.db.sql_list(“”“select distinct tasks from tabUser Tasks”“”)

you can access this in js using

frappe.boot.user_tasks

1 Like