Dear All,
I am lost ... I do not know what I have to use ...
I need to tranfer variable (mainly IDs) from page to page. I do not know if I have to use Placeholder, $_SESSION PHP variable or something else?
Many thanks in advance for your help!
Maxime
-
☆ A M B ☆
- 2,475 Posts
Any time you need a variable to persist across pageviews you basically have 3 choices:
1. $_GET -- append the variable to each url, eg: www.domain.com?myvar=123
Downside: insecure & easily bypassed, and not to mention a pain.
2. $_COOKIE -- store the value on the visitor’s computer
Downside: can be insecure & bypassed; HTTPS and encrypted cookies offer protection here, but they can be inconvenient
3. $_SESSION -- store data on the server.
This is often the best choice, but you have to spend time to ensure you sessions are managed properly
No matter what, make sure you always filter user-supplied data.
HTH
-
☆ A M B ☆
- 24,524 Posts
I tend to use both SESSION and COOKIE. Often I need to pass an ID from page to page to keep track of a visitor’s language choice. I have found that if a visitor sits for too long on one page, the SESSION has timed out (and this depends entirely on the server configuration), and he finds himself dumped back into the default language when he moves to another link. So the COOKIE acts as a backup to the SESSION.