Asterisk Variables

hello mates,

i made an asterisk game where ppl call a number and get some kind of a trivia game, they answer questions and so on …

my problem is that when i call from 3 or 4 phones at the same time to test it, some phones start to override other phones answers, now why will something like this happen ? :blush:

it`s like all the ppl who call this number, the asterisk opens only one session for all users :smiley: shared variables 0.o

well maybe you can post us some of the configuration. so we can see whas’t wrong.

Im guessing you must be storing the answers in the DB, or as a global variables. all normal variables are channel specific. So from you description i will put money on Global variables


yes most of my variables are global, they are used for purposes like counters and ETC. could that be the problem? if yes then how could i NOT use a global variable, what`s the point of having them then :smiley:


How are you defining the varibles ? basicly if you just specify a varible it isnt global, you have to secify it as global for it to be a global. But we dont know how you have specified them. post the cost that sets the varible in question and we can see what you have done.


i specify them under the [globals] context or with the set command, Set(test=1,g), i dont think that`s where the problem is

Yes that is the problem. you are detinging them under globals and when you are setting them you are also setting them as globals, thats what the g is doing

drop the g and then they are channel variables.


ian first of all thx :smile: but you got me wrong, i need the variables to be global so the dialplan for the game can access these variables from all contexts, my problem is that the global variables are becoming some sort of shared between all CALLERS :open_mouth:

if i set a variable ( not global ) in some context will the other contexts be able to access it? if not then i need a global variable, therefore i`m stuck with that problem :smiley:

another Q, if i use the AstDB instead of global variables will it solve the problem?


A global variable is as the name suggests global.
The same variable and its value is used by all callers.

If you mean you want a variable to be used by a caller as they progress through the dialplan then you have to prefix the variable with either _ or __ see the wiki for more details.

You could use the astdb and store and call them using the calls unique ID as the family then delete the family when the call ends.


ohhhh i see , well thx for this great info :smile: i`ll try to solve the problem in some other way, maybe use the AstDB or use the __ prefix.

Thanks again ian

Why not set it for the specific channel. You can also call the variable with say the channel name so it is unique.