Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4232504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:06:12+00:00 2026-05-21T02:06:12+00:00

on my website, the user has several options such as language, date and region.

  • 0

on my website, the user has several options such as language, date and region. when the user clicks anyone of those all is fine, the website adapts to the specific choices, but when they go to another page they loose all their choices, it would be nice if i found a way to keep them for their entire visit or perhaps 24hours.

example: bob goes onto my website, under the region setting, he clicks UK and as a result the website adapts and shows him a UK flag as a result. However, he when he goes to the next page he looses the flag and his region setting and has to choose his region setting all over again.

This is what I want to fix. I will post the whole code up in case this may help:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Loughborough University | Students Union</title>


<script type="text/javascript" src="scripts/changesheets.js"></script>
<?php include("scripts/lang_change.php"); ?>
<?php include("scripts/factoid_randomise.php"); ?>
<?php include("scripts/greeting.php"); ?>
<?php include("scripts/menu_change.php"); ?>
<?php include("scripts/lang_select.php"); ?>
<?php include("scripts/geo_loc_change.php"); ?>

<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/grey_white.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/orange_black.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/offwhite_blue.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">
//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','li','p');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;

sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 6 ) sz = 6;
startSz = sz;

if (!( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

cEl.style.fontSize = szs[ sz ];

for ( i = 0 ; i < tgs.length ; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
} 
</script>
</head>

<body>


<div id="wrapper">


<div id="header">



<?php 


if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'Japanese' :
echo "<div id='logo_japanese'></div>";
break;
case 'Chinese' :
echo "<div id='logo_chinese'></div>";
break;
default:
echo "<div id='logo'></div>";
break;
}
}
?>

<ruby style='float:right;  margin-top:-80px;'>
<rb><a href="javascript:ts('body',2)"><button style='background-image:url(/misc/FYP/images/textchange.png); width:31px; height:29px; border:none; '></button></a> </rb>

<rb><a href="javascript:ts('body',-1)" ><button style='background-image:url(/misc/FYP/images/textchangeb.png); width:23px; height:29px; border:none;'></button></a></rb>
<rb><button onclick='JavaScript:changeSheets(1)' style='background-image:url(/misc/FYP/images/theme1.png); width:29px; height:29px; border:none; '></button></rb>
<rb><button onclick='JavaScript:changeSheets(2)' style='background-image:url(/misc/FYP/images/theme2.png);width:29px; height:29px;border:none;' ></button></rb>
<rb><button onclick='JavaScript:changeSheets(3)' style='background-image:url(/misc/FYP/images/theme3.png);width:29px; height:29px;border:none;' ></button></rb>
<rb><button style='background-image:url(/misc/FYP/images/Britishflag.png);width:48px; height:20px;border:none;' ></button></rb>
</ruby>

<div class='greeting'>
<?php 


if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'German' :
echo welcome($tz_ger,$greetings_ger);
break;case 'Korean' :
echo welcome($tz_kor,$greetings_kor);
break;case 'Russian' :
echo welcome($tz_rus,$greetings_rus);
break;
case 'Japanese' :
echo welcome($tz_jap,$greetings_jap);
break;
case 'Chinese' :
echo welcome($tz_chi,$greetings_chi);
break;
default:
echo welcome($tz_eng,$greetings_eng);
break;
}
}
?></div>
</div>


<div id="line"></div>

<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {  
case 'German' :
echo makeMenu($links,$tabs_ger,$title);
break;
case 'Korean' :
echo makeMenu($links,$tabs_kor,$title);
break;
case 'Russian' :
echo makeMenu($links,$tabs_rus,$title);
break;
case 'Japanese' :
echo makeMenu($links,$tabs_jap,$title);
break;
case 'Chinese' :
echo makeMenu($links,$tabs_chi,$title);
break;
default:
echo makeMenu($links,$tabs_eng,$title);
break;
}
}

?>


<div id="line"></div>
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'German' :
echo changeGeoLoc($GeoLoc,$details_ger,$geoplugin);

break;case 'Korean' :
echo changeGeoLoc($GeoLoc,$details_kor,$geoplugin);

break;case 'Russian' :
echo changeGeoLoc($GeoLoc,$details_rus,$geoplugin);

break;case 'Japanese' :
echo changeGeoLoc($GeoLoc,$details_jap,$geoplugin);

break;
case 'Chinese' :
echo changeGeoLoc($GeoLoc,$details_chi,$geoplugin);

break;
default:
echo changeGeoLoc($GeoLoc,$details_eng,$geoplugin);
break;
}
}

?>
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'Russian' :
echo "<div id='welcome_pic_russian'>";
break;
case 'Japanese' :
echo "<div id='welcome_pic_japanese'>";
break;
case 'Chinese' :
echo "<div id='welcome_pic_chinese'>";
break;
default:
echo "<div id='welcome_pic'>
";
break;
}
}

?>





<div id="play_feature">
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'German' :
echo selectLang($h_ger,$lang_ger,$values,$h2_ger,$lang_ger2,$countries,$day,$month,$year);
break;case 'Korean' :
echo selectLang($h_kor,$lang_kor,$values,$h2_kor,$lang_kor2,$countries,$day,$month,$year);
break;
case 'Russian' :
echo selectLang($h_rus,$lang_rus,$values,$h2_rus,$lang_rus2,$countries,$day,$month,$year);
break;
case 'Japanese' :
echo selectLang($h_jap,$lang_jap,$values,$h2_jap,$lang_jap2,$countries,$day,$month,$year);
break;
case 'Chinese' :
echo selectLang($h_chi,$lang_chi,$values,$h2_chi,$lang_chi2,$countries,$day,$month,$year);
break;
default:
echo selectLang($h_eng,$lang_eng1,$values,$h2_eng,$lang_eng2,$countries,$day,$month,$year);
break;
}
}

?>




<?php
/*
@author geoPlugin (gp_support@geoplugin.com)
@copyright Copyright geoPlugin (gp_support@geoplugin.com)
*/

require_once('scripts/geoplugin.class.php');

$geoplugin = new geoPlugin();

$geoplugin->locate();

?>

<div id='menu2' style='width:250px; margin-left:-40px;'> 
</div>
<div style="color:#616161; margin-left:-20px;">
<blockquote>&#8216<?php 


if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'German' :
echo randomFactoid($factoidsg);
break;case 'Korean' :
echo randomFactoid($factoidsk);
break;case 'Russian' :
echo randomFactoid($factoidsr);
break;case 'Japanese' :
echo randomFactoid($factoidsj);
break;
case 'Chinese' :
echo randomFactoid($factoidsc);
break;
default:
echo randomFactoid($factoids);
break;
}
}


?>&#8217</blockquote>
</div>

</font>
</div></div>

<div id="homepage_text">
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_POST['languages'] as $language) {
switch ($language) {
case 'German' :
echo "<p>text</p>";
break;
case 'Korean' :
echo "<p>text.</p> ";
break;
case 'Russian' :
echo "<p>text </p>";
break;

case 'Japanese' :
echo "<p>text</p>";
break;
case 'Chinese' :
echo "<p>text</p>";
break;
default:
echo "<p>text</p>";
break;
}
}

?>



</div></div>
  </div>
</body>
</html>

This may be doable in cookies/sessions or something similar but i dnt know how i could incorporate cookies/session into this with the way i have coded it.

Any other suggestions other than cookies or sessions are welcome.

Any help greatly appreciated.

VERY IMPORTANT UPDATE
*After the suggestions below i tried this code:*

<?php
session_start(); //put this at the top of your script on all pages that need to remember
if(isset($_POST['languages']))
{
    $_SESSION['languages'] = $_POST['languages'];
}?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Loughborough University | Students Union</title>



<script type="text/javascript" src="scripts/changesheets.js"></script>
<?php include("scripts/lang_change.php"); ?>
<?php include("scripts/factoid_randomise.php"); ?>
<?php include("scripts/greeting.php"); ?>
<?php include("scripts/menu_change.php"); ?>
<?php include("scripts/lang_select.php"); ?>
<?php include("scripts/geo_loc_change.php"); ?>

<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/grey_white.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/orange_black.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/offwhite_blue.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">
//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','li','p');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;

sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 6 ) sz = 6;
startSz = sz;

if (!( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

cEl.style.fontSize = szs[ sz ];

for ( i = 0 ; i < tgs.length ; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
} 
</script>
</head>

<body>

<div id="wrapper">


<div id="header">



<?php 

if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'Japanese' :
echo "<div id='logo_japanese'></div>";
break;
case 'Chinese' :
echo "<div id='logo_chinese'></div>";
break;
default:
echo "<div id='logo'></div>";
break;
}
}
?>

<ruby style='float:right;  margin-top:-80px;'>
<rb><a href="javascript:ts('body',2)"><button style='background-image:url(/misc/FYP/images/textchange.png); width:31px; height:29px; border:none; '></button></a> </rb>

<rb><a href="javascript:ts('body',-1)" ><button style='background-image:url(/misc/FYP/images/textchangeb.png); width:23px; height:29px; border:none;'></button></a></rb>
<rb><button onclick='JavaScript:changeSheets(1)' style='background-image:url(/misc/FYP/images/theme1.png); width:29px; height:29px; border:none; '></button></rb>
<rb><button onclick='JavaScript:changeSheets(2)' style='background-image:url(/misc/FYP/images/theme2.png);width:29px; height:29px;border:none;' ></button></rb>
<rb><button onclick='JavaScript:changeSheets(3)' style='background-image:url(/misc/FYP/images/theme3.png);width:29px; height:29px;border:none;' ></button></rb>
<rb><button style='background-image:url(/misc/FYP/images/Britishflag.png);width:48px; height:20px;border:none;' ></button></rb>
</ruby>

<div class='greeting'>
<?php 


if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'German' :
echo welcome($tz_ger,$greetings_ger);
break;case 'Korean' :
echo welcome($tz_kor,$greetings_kor);
break;case 'Russian' :
echo welcome($tz_rus,$greetings_rus);
break;
case 'Japanese' :
echo welcome($tz_jap,$greetings_jap);
break;
case 'Chinese' :
echo welcome($tz_chi,$greetings_chi);
break;
default:
echo welcome($tz_eng,$greetings_eng);
break;
}
}
?></div>
</div>


<div id="line"></div>

<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {  
case 'German' :
echo makeMenu($links,$tabs_ger,$title);
break;
case 'Korean' :
echo makeMenu($links,$tabs_kor,$title);
break;
case 'Russian' :
echo makeMenu($links,$tabs_rus,$title);
break;
case 'Japanese' :
echo makeMenu($links,$tabs_jap,$title);
break;
case 'Chinese' :
echo makeMenu($links,$tabs_chi,$title);
break;
default:
echo makeMenu($links,$tabs_eng,$title);
break;
}
}

?>


<div id="line"></div>
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'German' :
echo changeGeoLoc($GeoLoc,$details_ger,$geoplugin);

break;case 'Korean' :
echo changeGeoLoc($GeoLoc,$details_kor,$geoplugin);

break;case 'Russian' :
echo changeGeoLoc($GeoLoc,$details_rus,$geoplugin);

break;case 'Japanese' :
echo changeGeoLoc($GeoLoc,$details_jap,$geoplugin);

break;
case 'Chinese' :
echo changeGeoLoc($GeoLoc,$details_chi,$geoplugin);

break;
default:
echo changeGeoLoc($GeoLoc,$details_eng,$geoplugin);
break;
}
}

?>
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'Russian' :
echo "<div id='welcome_pic_russian'>";
break;
case 'Japanese' :
echo "<div id='welcome_pic_japanese'>";
break;
case 'Chinese' :
echo "<div id='welcome_pic_chinese'>";
break;
default:
echo "<div id='welcome_pic'>
";
break;
}
}

?>





<div id="play_feature">
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'German' :
echo selectLang($h_ger,$lang_ger,$values,$h2_ger,$lang_ger2,$countries,$day,$month,$year);
break;case 'Korean' :
echo selectLang($h_kor,$lang_kor,$values,$h2_kor,$lang_kor2,$countries,$day,$month,$year);
break;
case 'Russian' :
echo selectLang($h_rus,$lang_rus,$values,$h2_rus,$lang_rus2,$countries,$day,$month,$year);
break;
case 'Japanese' :
echo selectLang($h_jap,$lang_jap,$values,$h2_jap,$lang_jap2,$countries,$day,$month,$year);
break;
case 'Chinese' :
echo selectLang($h_chi,$lang_chi,$values,$h2_chi,$lang_chi2,$countries,$day,$month,$year);
break;
default:
echo selectLang($h_eng,$lang_eng1,$values,$h2_eng,$lang_eng2,$countries,$day,$month,$year);
break;
}
}

?>




<?php
/*
@author geoPlugin (gp_support@geoplugin.com)
@copyright Copyright geoPlugin (gp_support@geoplugin.com)
*/

require_once('scripts/geoplugin.class.php');

$geoplugin = new geoPlugin();

$geoplugin->locate();

?>

<div id='menu2' style='width:250px; margin-left:-40px;'> 
</div>
<div style="color:#616161; margin-left:-20px;">
<blockquote>&#8216<?php 


if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'German' :
echo randomFactoid($factoidsg);
break;case 'Korean' :
echo randomFactoid($factoidsk);
break;case 'Russian' :
echo randomFactoid($factoidsr);
break;case 'Japanese' :
echo randomFactoid($factoidsj);
break;
case 'Chinese' :
echo randomFactoid($factoidsc);
break;
default:
echo randomFactoid($factoids);
break;
}
}


?>&#8217</blockquote>
</div>

</font>
<a href="http://s06.flagcounter.com/more/7ydE" ><img src="http://s06.flagcounter.com/count/7ydE/bg=FFFFFF/txt=000000/border=CCCCCC/columns=3/maxflags=25/viewers=Visitors/labels=0/pageviews=1/" alt="free counters" style="border:none; margin-left:15px;"/></a></div></div>

<div id="homepage_text">
<?php 
if(!isset($_POST['languages']))
{
        $_POST['languages'] = array('English');
}

foreach ($_SESSION['languages'] as $language) {
switch ($language) {
case 'German' :
echo "<p> </p>";
break;
case 'Korean' :
echo "<p></p> ";
break;
case 'Russian' :
echo "<p> </p>";
break;

case 'Japanese' :
echo "<p>。</p>";
break;
case 'Chinese' :
echo "<p></p>";
break;
default:
echo "<p></p>";
break;
}
}

?>



</div></div>
  </div>
</body>
</html>

WHICH DIDNT WORK. ANY reasons why, seem to have done everything people have told me?**

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:06:12+00:00Added an answer on May 21, 2026 at 2:06 am

    Sessions or Cookies are definitely the best way to do it:
    The thing is that you have to have a way to connect it with the user.
    Technically you could store it in a database and either store a cookie on the user’s computer that says which database entry to read or even store the user’s ip and relate it to the user that way (although that’s a pretty unreliable method). But that’s all probably an overkill for what you want to do.

    Here is how to incorporate sessions into your code:

    Posting only one language

    For a start lets reformat what you already have.
    You have $_POST['languages'] which is actually an array that contains one result.
    In that case you may as well make it a string and call it $_POST['language']

    You also must remember to post it correctly (in the singular) when the user originally chooses his language.

    First off you have to start the session at the top of the page:

    session_start();
    

    Next you have to save the user’s selection to a session variable.

    We are going to check if the user has selected a language (from the $_POST variable) and, if yes, assign it to a $_SESSION variable.

    if ($_POST['language']) {
        $_SESSION['language'] = $_POST['language'];
    }
    

    The session variable functions identical to any other variable, but it will carry on from page to page until the session ends.

    Now we are going to check what the language is

    This is pretty simple. In your example you checked what the language was by finding what the user had ‘posted’:

    isset($_POST['languages'])
    

    In our new code, we are going to check the session variable, which we have just saved:

    $_SESSION['language']
    

    Choosing the right language

    No need to make $_POST['languages'] an array and then use a foreach to loop through it.

    A simpler way of doing it would be like this:

    switch($_SESSION['language']) {
        case "german": //do german suff
        case "english": //do english suff
        etc...
    }
    

    Additionally, you first checked if the session tag was empty and then put a value if it wasn’t.
    You can skip that step and instead put inside the switch() { } at the end, after all the cases:

    default: //do default language stuff
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our website has one section which often changes to match the user. (examples are
my website has a log in by open id feature. When a user logs
I've got a website that has a form that the user can type in.
We have not purchased an SSL certificate so the user of our website has
I have a real estate website that has several categories. And i want the
I have a website with articles. When a user has authenticated an application and
I have a website and I am user of several Affiliate Programs. How can
I manage a website for an organization that has a network where several hundred
I am building a web site where the user has to digitally sign a
I'm building a website with user generated content. On the home page I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.