I am storing some information in a Session variable. I have a Structure that contains a number of separate items including login data and shopping basket data. At the end of the Page_LoadComplete event I store the structure as follows:
Current.Session("SessionPool") = Spl
And I retrieve it at the start of the Page_Load event as follows:
Spl = Current.Session("SessionPool")
Throughout my logic I refer to items within the structure such as spl.loginrow (a datarow) and spl.basket (a datatable).
I am testing the (remote) web site from two independent PCs. I change the quantity of items for one line in the shopping basket on one PC then, on the other PC, I refresh the basket and, hey presto, it reflects changes I have made on the first PC.
This suggests to me that the session variable is being shared across all sessions somehow - i.e. it is being managed at an application level. Does this make any sense? Any suggestions about what kind of dumb mistake I could have made here?
Thanks for the replies. It is declared (in a module) like this
Public Structure SessionPool
Public RowLogin As DataRow
Public TblBsk As DataTable
Public BskStatus As BasketStatus
Public Administrator As Boolean
Public AdminUser As String
End Structure
Public Spl As SessionPool
If I define, retrieve and update the structure within master page code behind then pass the structure as a parameter ByRef through to the routines in the module, is that a possible solution?
I bit the bullet and removed all my modules. I'm not happy with my final solution which effectively resulted in me putting lots of code that I felt logically belonged in separate files in a single code-behind module but it was the quickest solution and I
am under some time pressure. I hope to come back to it at some tage and implement a more elegant solution.
Member
10 Points
80 Posts
"Global" session data
May 20, 2011 11:23 AM|Glasgow|LINK
I am storing some information in a Session variable. I have a Structure that contains a number of separate items including login data and shopping basket data. At the end of the Page_LoadComplete event I store the structure as follows:
And I retrieve it at the start of the Page_Load event as follows:
Throughout my logic I refer to items within the structure such as spl.loginrow (a datarow) and spl.basket (a datatable).
I am testing the (remote) web site from two independent PCs. I change the quantity of items for one line in the shopping basket on one PC then, on the other PC, I refresh the basket and, hey presto, it reflects changes I have made on the first PC.
This suggests to me that the session variable is being shared across all sessions somehow - i.e. it is being managed at an application level. Does this make any sense? Any suggestions about what kind of dumb mistake I could have made here?
Contributor
3670 Points
943 Posts
Re: "Global" session data
May 20, 2011 11:52 AM|smcoxon|LINK
How is Spl defined? Is it shared? I.e. is the Loginrow or basket table created as shared?
Smcoxon
No Gem is ever polished without some friction.
Participant
1568 Points
572 Posts
Re: "Global" session data
May 20, 2011 11:55 AM|karthic_85|LINK
session cant be shared across application,spl should have static content in it...
Member
10 Points
80 Posts
Re: "Global" session data
May 20, 2011 12:20 PM|Glasgow|LINK
Thanks for the replies. It is declared (in a module) like this
so it's not explicitly shared. Any thoughts?
Star
14075 Points
3271 Posts
Re: "Global" session data
May 20, 2011 12:52 PM|roopeshreddy|LINK
Hi,
May be the structure is inside a static class, like the below code,
If yes, then that is the problem causing you.
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
Member
10 Points
80 Posts
Re: "Global" session data
May 20, 2011 12:58 PM|Glasgow|LINK
Thanks. It's inside a module:
Is that OK?
Participant
1568 Points
572 Posts
Re: "Global" session data
May 20, 2011 01:25 PM|karthic_85|LINK
Module
s counterparts tostatic
classes.When your class is designed solely for helper functions.you define it as Module
You cannot have variables or objects that changes per user....
Contributor
3670 Points
943 Posts
Re: "Global" session data
May 20, 2011 01:29 PM|smcoxon|LINK
Have you tried:
to create a new instatnce of sessionPool each time a user opens this page
Smcoxon
No Gem is ever polished without some friction.
Member
10 Points
80 Posts
Re: "Global" session data
May 20, 2011 01:53 PM|Glasgow|LINK
Thanks. Oh dear!
If I define, retrieve and update the structure within master page code behind then pass the structure as a parameter ByRef through to the routines in the module, is that a possible solution?
Member
10 Points
80 Posts
Re: "Global" session data
May 20, 2011 04:55 PM|Glasgow|LINK
Sorry smcoxon, I was replying to previous post. I had considered the 'new' approach. I will try.
Member
10 Points
80 Posts
Re: "Global" session data
May 23, 2011 11:09 AM|Glasgow|LINK
I bit the bullet and removed all my modules. I'm not happy with my final solution which effectively resulted in me putting lots of code that I felt logically belonged in separate files in a single code-behind module but it was the quickest solution and I am under some time pressure. I hope to come back to it at some tage and implement a more elegant solution.