tags:

views:

44

answers:

2

I have my language files in /language/ en.php, se.php etc

Here a snippet from one file:

$lang = array (

    'IMAGE_NOT_FOUND' => 'Kunde ej hitta bilden.',
    'ACCOUNT_ALREADY_ACTIVATED' => 'Ditt konto har redan aktiverats.'
    ...

);

Current code

if (isset($_GET['setlang']) && $_GET['setlang'] == 'en') include('language/en.php');
elseif (isset($_GET['setlang']) && $_GET['setlang'] == 'se') include('language/se.php');

How would I do to save lang for next visit even if user closes browser?

A: 

You would could a cookie if the user does not have to login, otherwise you could save it in the database.

SeanJA
+1  A: 

Take a look at sessions for saving data across browser requests.

Amber
The question was if they close the browser... not load a different page on the same site...
SeanJA
It's unclear whether they were referring to a single window out of many, or a full shutdown of the session. If the latter, then yes, a full cookie would be more appropriate.
Amber