I’m trying to add some data into data dict in a session. Why?
I want that my app use a specific value selected by the user in all the pages without passing it through get method. the reason for this is i have some pages that show information based in the value selected by the user.
Example: you have two kids and when you select one of them, in all the app the results are related with the kid selected. passing this value in every page it is not a good idea.
something like frappe.session.kid_selected .
Any idea to do what i want even if it is in another way.
Add it to cache.
value = frappe.cache().get_value(key)
# or pass a generator method
# do something
value = frappe.cache().get_value(key, generator_func)
Thanks for your answer. That’s similar what i need but only for the user in the page. Another user have another kids.
Your key should have user as a part of it.
@rmehta , @geekroot
What do you means by Add it to cache? Where should i add the code ? in python? which python file ya? Can you give me a hint please? Thank you very much, your help is highly appreciated.
Yes, the code above is python code. The file you need to use to set the value is the file related with the page/doctype where the user will select the value to be cached.
Can you please give me very simple example that u implemented? Tyvm
Sorry but that was two years ago and i have no access to the project anymore.
@geekroot @rmehta can you help me by saying that how can i unset session that i setted by above method
@shahid_ecit I think this can help you: frappe.cache().delete_key(“key_name”)
@geekroot thanks for replay it is working also thanks very much
@shahid_ecit thanks you for being part of the community