This is a discussion on SESSION Array problem - possibly different PHP versions? within the PHP General forums, part of the PHP Programming Forums category; Hi All, I have a problem that only occurs on our live server and not our local server. It works ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi All, I have a problem that only occurs on our live server and not our local server. It works fine locally. Basically I am using a session array to store values of product colours. A user can add colours to the session array. The session is defined as follows: $_SESSION['color'][$counter] = $color; Obviously the first time we validate and the $counter is set to 0. When more colours are added the $counter variable increments and should increment the value of the array. The colours are added through a popup window. Before I open the popup window I print_r($_SESSION['color']) to view the contents of the array and make sure that they are valid and it is an array. Output is as follows: [color] => Array ( [0] => #339933 [1] => #cccc00 ) etc... Then once the popup opens I do the same print_r And it now shows: [color] => #339933 There fore it isn't an array of colors within the session array. How can PHP change this? Also the strange thing is that locally it works fine but not live. So I am guessing that there is a problem with a certain version of PHP? Also Im not sure what else could be causing this problem? Any ideas or hints would be appreciated. Thanks Kind regards, Angelo Zanetti Application Developer ________________________________ Web: http://www.elemental.co.za |
|
|||
|
On Mon, Mar 10, 2008 at 9:22 AM, Angelo Zanetti <angelo@elemental.co.za> wrote:
> There fore it isn't an array of colors within the session array. How can PHP > change this? Also the strange thing is that locally it works fine but not > live. So I am guessing that there is a problem with a certain version of > PHP? From where is the color data coming in to the script, a database? Check to make sure that the array is being populated. Also, you're not attempting to pass the session from your dev box to your live box, are you? -- </Dan> Daniel P. Brown Senior Unix Geek <? while(1) { $me = $mind--; sleep(86400); } ?> |
|
|||
|
-----Original Message----- From: Daniel Brown [mailto:parasane@gmail.com] Sent: 10 March 2008 16:04 To: Angelo Zanetti Cc: php-general@lists.php.net Subject: Re: [php] SESSION Array problem - possibly different PHP versions? On Mon, Mar 10, 2008 at 9:22 AM, Angelo Zanetti <angelo@elemental.co.za> wrote: > There fore it isn't an array of colors within the session array. How can PHP > change this? Also the strange thing is that locally it works fine but not > live. So I am guessing that there is a problem with a certain version of > PHP? From where is the color data coming in to the script, a database? Check to make sure that the array is being populated. Also, you're not attempting to pass the session from your dev box to your live box, are you? Hi Daniel, thanks for the reply. The system works as follows. There is a colour picker, when a user clicks on a colour then it opens a popup window with the color set as a GET variable. They can then enter the price per colour etc... once done, they save it. It then saves the details to a session. The user then closes the window and it refreshes the parent page which has the colour picker and a listing of selected colours already choosen, after the refresh it shows the array values (print_r) and is correct the first time: [color] => Array ( [0] => #339933 Then if they do the same procedure again, once the popup opens it shows the session variable as: [color] => #339933 But nothing has been done to the SESSION variables since the save, so somehow between the the click and the popup opening something strange is happening. Like I mentioned it works on a local laptop as well as our local server so its strange, I have tried many times closing the browser to ensure all sessions are cleared. Any ideas what might be causing this error? Thanks very much |
|
|||
|
Put a print_r($_SESSION) at the top and bottom of your page code so you can see
what's happening. Also check your code that updates the session assignment by the GET value. It appears your code maybe unset()ing the session assignments. Are you using Cookies? If so, check this code carefully as it can cause non obvious things depending on whether the client machine has cookies enabled or disabled. Angelo Zanetti wrote: > Hi All, > > I have a problem that only occurs on our live server and not our local > server. > > It works fine locally. > > Basically I am using a session array to store values of product colours. A > user can add colours to the session array. > > The session is defined as follows: > > $_SESSION['color'][$counter] = $color; > > Obviously the first time we validate and the $counter is set to 0. > > When more colours are added the $counter variable increments and should > increment the value of the array. > > The colours are added through a popup window. Before I open the popup window > I print_r($_SESSION['color']) to view the contents of the array and make > sure that they are valid and it is an array. > > Output is as follows: > > [color] => Array ( [0] => #339933 [1] => #cccc00 ) etc... > > > > Then once the popup opens I do the same print_r > > And it now shows: [color] => #339933 > > There fore it isn't an array of colors within the session array. How can PHP > change this? Also the strange thing is that locally it works fine but not > live. So I am guessing that there is a problem with a certain version of > PHP? > > Also Im not sure what else could be causing this problem? > > Any ideas or hints would be appreciated. > > Thanks > > > > > Kind regards, > Angelo Zanetti > Application Developer > ________________________________ > > > Web: http://www.elemental.co.za > > |
|
|||
|
-----Original Message----- From: Al [mailto:news@ridersite.org] Sent: 10 March 2008 18:23 To: php-general@lists.php.net Subject: [php] Re: SESSION Array problem - possibly different PHP versions? Put a print_r($_SESSION) at the top and bottom of your page code so you can see what's happening. Also check your code that updates the session assignment by the GET value. It appears your code maybe unset()ing the session assignments. Are you using Cookies? If so, check this code carefully as it can cause non obvious things depending on whether the client machine has cookies enabled or disabled. --------------------- Thanks will do so going to check the unset() as well as the print_r at top and bottom, also I am not using cookies hope to get this sucker working. Will keep you posted. Angelo |