i’m building a php switcher to add multilanguage capability to my site.
Every content in MySQL has a language-specific text that I want to retrieve according to the active language.
At the beginning, I thought to build a tailored table in MySQL to store the languages status.
For example:
ITALIAN 1
ENGLISH 0
..where 1 means that language is active, and 0 means is off.
Every time the user switch language, I call this table and change the language status. Then, at the end of the call, I refresh the page and php retrieve the right contents.
This seemed a good idea till I figured out that the languages status in MySQL could change every time a user switch. So, if a user is viewing the site in Italian, and other user switch to English at the same time, the first user will view the English as well.
My question is: how could I store the languages status for the specific user, avoiding change the languages status for every other user ?
Thanks a lot
Don’t use the database. Set a
$_SESSIONvariable instead (and don’t forget to callsession_start()before you modify it). (Php Manual)