Reputation: 77
Having a weird issue. A user logs in and I assign their pricing discount matrix as a query to a session variable. Then on the product pages I lookup their discount based on the products Pricing Group. This code has been working fine and continues to work for all users but this one in particular. So this is the scenario.
Login process sets this based on some data from a database
<cfset SESSION.Vendor.PriceMatrix = #qryPriceMatrix# />
The query data would look something like this. So two columns.
| Discount | VendorCategory |
|----------|----------------|
|0.2 | SWIPES |
|0.2 | TANTUS |
|0.2 | TOPCO |
|0.2 | VOODOO |
Then on the product pages I simply query that session variable like so.
<cfquery name="GetYourPrice" dbtype="query">
SELECT Discount FROM SESSION.Vendor.PriceMatrix
WHERE VendorCategory = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#PricingGroup#" maxlength="20">
</cfquery>
The issue I am having is immediately following this query of the session variable it sets all of the values of the Discount column in the session variable to 0 like so.
| Discount | VendorCategory |
|----------|----------------|
|0 | SWIPES |
|0 | TANTUS |
|0 | TOPCO |
|0 | VOODOO |
I have no idea why or how this is happening since I would think in order for this to happen I would have to set the session variable but there is no cfset statement. Again this code works fine on all the other user accounts. Has anyone ever run into something similar? A query of a session var containing a query that then sets the first column to zeros?
Upvotes: 0
Views: 96
Reputation: 14859
this code works fine on all the other user accounts
Are you 100% sure about that? Odds are this is just the first account where this has been reported. Feels like a memory leak issue of sorts. If you're dealing with CFCs cached in applicaiton
or session
scopes, are all of the function variables local
or var
scoped to their functions?
If there's any code that sets a default value of 0
for every VendorDiscount
in a query, change 0
to -1
and see if that's the code that getting called incorrectly.
How often are users logged into the system and not purchasing anything? If not very often, then you're adding to session memory with little ROI. Personally, I wouldn't cache this list of discounts. I would just query the DB and have it return the full price, discount amount and adjusted price in the main query.
Upvotes: 1