Asked by:
set a session variable in a shared function

Question
-
User-125499312 posted
how do i set a session variable in a shared function?
thx 4 ur help
Sunday, May 27, 2018 7:08 PM
All replies
-
User1120430333 posted
What difference would it make that you are using a common function used by all users? Session variables are used by a user's induvial session, which is in isolation between each user. So the common function would only be working with a user and its session objects at the time that the user is using the common function.
Sunday, May 27, 2018 7:19 PM -
User-125499312 posted
here is what i am trying to do.
i have a shared function in my behind - i need to pass a value back to the front end javascript
i am trying to do this using a session variable
would you have any other suggestions?
thx
Sunday, May 27, 2018 7:25 PM -
User1120430333 posted
The link should help you.
https://stackoverflow.com/questions/15519454/how-to-access-session-variables-and-set-them-in-javascript
Sunday, May 27, 2018 7:53 PM -
User-125499312 posted
the article shows how to set a session var in JS - i need to set the session var in a shared function
Sunday, May 27, 2018 7:57 PM -
User1120430333 posted
the article shows how to set a session var in JS - i need to set the session var in a shared function
Your friend is Bing or Google.
https://msdn.microsoft.com/en-us/library/ms178581.aspx
Sunday, May 27, 2018 8:12 PM -
User1724605321 posted
Hi yzidell,
I agree with @DA924 , and you can use HttpContext.Current to get current Http Context; from which you can access: Session, Request, Response .
In addition, you could also use Ajax to call server side function , and pass the variables to client side in success callback function with Ajax :
https://www.c-sharpcorner.com/article/ajax-in-asp-net/
Best Regards,
Nan Yu
Monday, May 28, 2018 5:38 AM