Page 1 of 1

SESSION VALUE CHANGE AUTOMATICALLY ????

Posted: Thu Jun 11, 2009 7:11 am
by silenceghost
I'M USING MVC, SMARTY IN MY PROJECT.
PROBLEM IS THAT WHEN I SET THE SESSION VARIABLE AT TOP OF THE PAGE IT CHANGES AUTOMATICALLY
EG..

Code: Select all

 
session_start();
print_r($_SESSION);//changes $_SESSION['LANGUAGE'] value is now 'image'
//This was changes automatically don't know how
 //Get Variable comes like /LANGUAGE/0 OR /LANGUAGE/1
$Application  = Application::GetInstance();//This Process all the Get variable and other thing comming from url 
$Application->Startup();    
if(isset($_GET['LANGUAGE']) && trim($_GET['LANGUAGE'])!=''){
    $_SESSION['LANGUAGE']=$_GET['LANGUAGE'];
}else if(!isset($_SESSION['LANGUAGE'])&&trim($_SESSION['LANGUAGE'])==''){
    $_SESSION['LANGUAGE']=0;
}
//Again Session is set to normal Value 0 or 1
 
print_r($_SESSION);
 
When there is GET VARIABLE SET it session shows normal result but in absence of get it overide the session even if the session value is 0 or 1.

I'm sure in page there is no other value than 0 or 1 of session LANGUAGE
but when i refresh the page and try to exit() on first session print (i.e print_r($_SESSION)) it changes and show ($_SESSION['LANGUAGE']=>images) and when i print at last it show normal result.

I'm not getting that even if SESSION value is normal at the end of the code why it changes at begining.

Also try with different session name but still the value change it is blowing up my mind i've been trying to solve this case for last two days

if you have been experincing such thing .

Re: SESSION VALUE CHANGE AUTOMATICALLY ????

Posted: Thu Jun 11, 2009 12:49 pm
by AlanG
Do you have register_globals off?

Run this code in your script:

Code: Select all

echo 'register_globals = ' . ini_get('register_globals');
1 = on, 0 = off.

The register globals could be interfering with your script. I believe this, as you are using $_SESSION['LANGUAGE'] and $_GET['LANGUAGE']. Try turning it off and seeing if the problem still exists.

If it is on, but you do not have access to the server, (and assuming your using apache) you can configure your .htaccess file and simply add this line to turn it off.

Code: Select all

php_flag register_globals off

Re: SESSION VALUE CHANGE AUTOMATICALLY ????

Posted: Fri Jun 12, 2009 12:50 am
by silenceghost
-I had already tried ini_get register global before posting this message.
-putting the value on .htaccess doesnot solve my problem

New Solution Tried with no output
i though may be it was of smarty calling the session
{$smarty.session.var}
so i replace and assign the session and use that variable, that also doesn't solve
$this->assign('smarty_session',$_SESSION);

Re: SESSION VALUE CHANGE AUTOMATICALLY ????

Posted: Sun Jun 28, 2009 1:14 am
by silenceghost
New Solution Works
It is due to smarty i don't know why but in smarty template page
my image source is completely wrong path that doesnot exists so the value inside the src src="image/test.gif" is assinging the value in session when i removed those image which are not in existence it worked