I want to save the language in a session using $_GET[''] method:
<a href="?lang=fr">French</a>
<a href="?lang=en">English</a>
By default the site language is in french. the site language will be changed if the user choose one from the links above. and then even thought the $_GET['lang'] is not set, i want the $_SESSION['lang'] always saves the last language choosen by the user.
I tried this but its not logic, i know..
$languages = array('en', 'fr');
if(isset($_GET['lang']) AND in_array($_GET['lang'], $languages)){
$_SESSION['lang'] = $_GET['lang'];
}else{
$_SESSION['lang'] = "fr";
}
require_once('languages/'.$_SESSION['lang'].'.php');
what should I do then to save the last language is session variable?
session_start()