Managing variables in a multiuser app

Hi,

Are variables private or global? Here is my scenario -

Invoice Number Customer Total UserId
123 Tom Tom Club 1627.88 jackc
124 Shade Street Capital 727.22 johns

Jack C runs a page which retrieves the last invoice number with his userid. This number (123) is stored in a variable called lastInvoiceId.

A micro second later John S runs the same page and the number (124) is saved to lastInvoiceId.

Are those 2 lastInvoiceId variables distinct for each user or will Jack now see the details of
invoice 124 when his screen loads?

If the latter is the case, how do I seperate the information for each user?

Thanks
Steve
Would the lastOrderId for user A change?

If so, how can I ensure the variables are unique for each user? Is it possible to create variables on the fly which may have a name such as UserALastUserId, etc.

Thanks
Steve

a variable is unique to the user in the browser, if I change to dark mode on my app it doesn’t change it to dark mode for everyone who has my app open. If your calling the database tho and the call happens after the insert and not filtering for the user its likely that by the time jackc’s request gets to the database johns has already been added and so you would get johns invoice returned.

1 Like

Thanks Sam.

I will be filtering by user so that will not be an issue.