What is the secure way for passing a variable from one page to another?

Initially to pass one variable from one page to another, what i did was

GET request from Url and store it to a hidden div , and using jquery i pick that value and pass it to next page . eg

[php]
[/php]

Now what i am doing is
GET request from url and storing it in a javascript variable for eg

[php]

<?php $searchKey=$_POST['q']; $db=$_POST['db']; ?> .......... .......... [/php]

Which is the best way for passing variable ??
Or is it good to pass variable via session??

I don’t know whether it is the right / proper way to do it but I always use session variables.

But how do u access them in javascript???

I have a feeling this might be a XY

Please explain what you wish to do
page 1, javascript?
save what kind of data
page 2, also javascript?
get what kind of data

Then we can probably advise how it would be sensible to solve this :slight_smile:

btw: You can get variables/data from server side to js using ajax
http://api.jquery.com/jquery.ajax/

Sponsor our Newsletter | Privacy Policy | Terms of Service