global var vs session vs something else maybe? [message #169840] |
Tue, 28 September 2010 04:34 |
Kentor
Messages: 5 Registered: September 2010
Karma: 0
|
Junior Member |
|
|
Hello,
I'm running a query in initialFile.php which then displays some
information on the page. Later, the user has the option of clicking on
a load button, which loads a map to display this information on a
Google map.
initialFile.php has a query (that I need sometime later) and this page
has a button which runs a javascript function in loadMap.js which
makes an AJAX call to another file ajaxFile.php (where I need the
query so I can run it again).
I don't want the user to be able to see the query through cookies or
anything unsafe for the site.
My question is the following, is there a way to create a global
variable in initialFile.php and then access it in ajaxFile.php ? If
so, how would I do it? I have tried and failed using several options.
Is it better to just use a session to pass that query?
Would you have any better ways of doing this?
Thank you so much!
|
|
|
Re: global var vs session vs something else maybe? [message #169841 is a reply to message #169840] |
Tue, 28 September 2010 05:10 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Kentor wrote:
> Hello,
>
> I'm running a query in initialFile.php which then displays some
> information on the page. Later, the user has the option of clicking on
> a load button, which loads a map to display this information on a
> Google map.
>
> initialFile.php has a query (that I need sometime later) and this page
> has a button which runs a javascript function in loadMap.js which
> makes an AJAX call to another file ajaxFile.php (where I need the
> query so I can run it again).
> I don't want the user to be able to see the query through cookies or
> anything unsafe for the site.
Then use session, user will at most see the session key, no clue what values
may be stored.
I wouldn't really store the whole query in the session, but only the values to
be used in the query, that way you can do more with the values, like display
them or...
> My question is the following, is there a way to create a global
> variable in initialFile.php and then access it in ajaxFile.php ?
$_SESSION is the closes thing, you could store it on a file which you create
with the script, but that's kind of reinventing the wheel.
--
//Aho
|
|
|
Re: global var vs session vs something else maybe? [message #169842 is a reply to message #169840] |
Tue, 28 September 2010 05:11 |
rf
Messages: 19 Registered: September 2010
Karma: 0
|
Junior Member |
|
|
"Kentor" <kentor(at)gmail(dot)com> wrote in message
news:7d069665-e87d-4b99-97db-951c1ebba992(at)q2g2000vbk(dot)googlegroups(dot)com...
> Hello,
>
> I'm running a query in initialFile.php which then displays some
> information on the page. Later, the user has the option of clicking on
> a load button, which loads a map to display this information on a
> Google map.
>
> initialFile.php has a query (that I need sometime later) and this page
> has a button which runs a javascript function in loadMap.js which
> makes an AJAX call to another file ajaxFile.php (where I need the
> query so I can run it again).
> I don't want the user to be able to see the query through cookies or
> anything unsafe for the site.
>
> My question is the following, is there a way to create a global
> variable in initialFile.php and then access it in ajaxFile.php ? If
> so, how would I do it? I have tried and failed using several options.
> Is it better to just use a session to pass that query?
> Would you have any better ways of doing this?
Session cookies. It's all in the manual.
|
|
|
Re: global var vs session vs something else maybe? [message #169861 is a reply to message #169841] |
Tue, 28 September 2010 20:11 |
Kentor
Messages: 5 Registered: September 2010
Karma: 0
|
Junior Member |
|
|
On Sep 28, 1:10 am, "J.O. Aho" <u...@example.net> wrote:
> Kentor wrote:
>> Hello,
>
>> I'm running a query in initialFile.php which then displays some
>> information on the page. Later, the user has the option of clicking on
>> a load button, which loads a map to display this information on a
>> Google map.
>
>> initialFile.php has a query (that I need sometime later) and this page
>> has a button which runs a javascript function in loadMap.js which
>> makes an AJAX call to another file ajaxFile.php (where I need the
>> query so I can run it again).
>> I don't want the user to be able to see the query through cookies or
>> anything unsafe for the site.
>
> Then use session, user will at most see the session key, no clue what values
> may be stored.
>
> I wouldn't really store the whole query in the session, but only the values to
> be used in the query, that way you can do more with the values, like display
> them or...
>
>> My question is the following, is there a way to create a global
>> variable in initialFile.php and then access it in ajaxFile.php ?
>
> $_SESSION is the closes thing, you could store it on a file which you create
> with the script, but that's kind of reinventing the wheel.
>
> --
>
> //Aho
I guess you're right. Using a session would be the best way. Thanks!
|
|
|