<?php
	session_start();
	$goback = $_SERVER['HTTP_REFERER'];
	//$getlangid = $_GET["langid"];
	if(isset($_GET['language'])){
		$lang = $_GET['language'];
		// register the session and set the cookie
		$_SESSION['language'] = $lang;
		setcookie("language", $lang, time() + (3600 * 24 * 30));
	}else if(isset($_SESSION['language'])){
		$lang = $_SESSION['language'];
	}else if(isset($_COOKIE['language'])){
		$lang = $_COOKIE['language'];
	}else{
		$lang = 1;
	}
	header("Location:$goback");
?>