You are here: Re: Problem with session variables? « All PHP « IT news, forums, messages
Re: Problem with session variables?

Posted by Nicole on 10/25/05 13:40

Hiya

I'm confused now as i thought

$HTTP_SESSION_VARS ["country"] = $country;

meant that i could refer to the session variable as $country ?

Also I get 'uk' from $country in the 'thiscountry.php' which i thought
suggested that $country was refering to the session variable?

However, I did what you suggested and changed functions so it now looks
like:

<?php session_start();
session_register ("country"); // Create a session variable called name
$HTTP_SESSION_VARS ["country"] = $country;
$country="UK";
?>
<?php
if($FuncToExec == "countrySelectUS"){
countrySelectUS();
}?>

<html>
<head>
<meta http-equiv="refresh" content="12; URL=thiscountry.php">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
function countrySelectUS() {
$_session['country']="US";
echo "new country is: " .$_session['country'];
}
?>
</body>
</html>

However, I still get the same problem, I click on the link, functions.php
displays showing 'new country is: US' and then I move automatically to
thiscountry.php where it says 'You are in UK'

which I dont understand :(

N



"Ian B" <ianbambury@gmail.com> wrote in message
news:1130232597.162435.299180@g14g2000cwa.googlegroups.com...
> "the change in value for country isnt being 'stored' as part of the
> session" because you are saving it in the local (to the function) var
> $country which goes out of scope when the function ends
>
> Either use
>
> $_SESSION['country']
>
> or use
>
> "global $country"
>
> The former is preferable for readability and still leaves you with
> $country to use locally.
>
> Ian
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация