Create another session variable that keeps track of the total ... as they add
and remove items. That would be much more efficient than a query each time.
You say "global" ... not sure what you mean by that.
If you mean PHP "register_globals" ... that should be DISABLED (OFF).
Usually, "off" is the server's default setting. There should be no ability
to pass variables globally between scripts. period.