473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SESSION puzzle

Tom
I've been researching this for a while now -- perhaps someone here
knows the explanation.

I uploaded to my remote host (system info: PHP Version 4.3.11, FreeBSD
metis.cleverdot.com 5.3-RELEASE-p13 FreeBSD 5.3-RELEASE-p13 #0:
ke*******@kernbuild.kgix.net:/usr/obj/usr/src/sys/KGIX-SMP-PMAP i386) a
script that uses $_SESSION variables to control output between page
loads. (I've pasted what I think is the relevant code at the end of
the message.)

What I want the script to do: create an html string (a panel) that
contains some random data (an ID) that will be saved to the session.
Thus, if the page is reloaded, the same panel with the same ID will be
displayed. A user can modify the panel using an input field, which
will then be saved to session and redisplayed upon reload. There's
also a button to get a completely new panel. On my local WAMP
installation (system info: PHP Version 5.0.3, Windows NT build 2600),
everything works fine and SESSION data gets saved. This has worked on
2 different but similar local WAMP servers. See simplified code at
bottom.

The problem: On the remote server, SESSION data does not get saved.
I've never had this problem with any other scripts I've run on this
host. The only anomalies in this script that I can think of:

1. include path gets changed so I can use my own locally cobbled config
of PEAR without conflicts (Script does not require PEAR, however, and I
reran it without it but this did not solve problem)

2. session variable is getting saved within a function (not in main
scope of script)

Like I said, no problem on my local server, but won't work on the
remote host. I've echoed the $_SESSION variables and confirmed that
the variables are not being saved between page reloads.

I just checked with my host and they set up a simple page for me that
demonstrated that sessions are operating

Probably something silly and obvious but I can't figure it out for the
life of me. And the fact that it works in one environment and not the
other has me utterly baffled and make me think it's something exotic,
beyond my reckoning. Any help you can offer will be appreciated.

Thanks,

Tom

Essential Code:

if ( !session_id() ) { session_start(); }

# POST : get_new_panel
if ( $_POST['get_new_panel'] )
{
$_SESSION['panel'] = '';
$_SESSION['form_input']['valid']['name'] = '';
}

# new panel
if ( empty($_SESSION['panel']) )
{
$HTML['panel'] = cx_panel();
}

# add user input to panel
elseif ( !empty($_SESSION['form_input']['valid']['name']) )
{
$HTML['panel'] = cx_panel($_SESSION['form_input']['valid']['name'],
$_SESSION['panel']);
}

# existing panel
else
{
$HTML['panel'] = $_SESSION['panel'];
}

echo $HTML['panel'];

note: the cx_panel function both returns html string and saves it to
$_SESSION['panel'].

Dec 29 '05 #1
1 1582
Tom
In response to my own question, I finally discovered this:

fondman at hotmail dot com
06-Dec-2005 02:47

I just solve a problem about $_SESSION variable.
For example, you set $_SESSION['username'] = "Michael" already, later,
you have a variable $username = "Chi" in a php script
After PHP 4.4.0, $_SESSION['username'] is still "Michael".
However, In PHP 4.3.*, $_SESSION['username'] is also changed to "Chi".

Be Careful, if the php version is lower than 4.4.0!
http://us2.php.net/manual/en/ref.session.php#59433

My problem was a variation on this theme. It does pose a bit of
problem for the framework I put together. Glad to hear it's been fix
in PHP 4.4+.

Dec 29 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shige | last post by:
This kinda puzzle me. I was trying to pass a piece of information from page to page, so i use session. It works fine until i created directories to organize my pages. Say, from...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
0
by: xavier vazquez | last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
5
by: ashish0799 | last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM Jigsaw puzzles. You would have solved many in your childhood and many people still like it in their old ages also. Now what you have got to do...
3
by: oncue01 | last post by:
Word Puzzle Task You are going to search M words in an N × N puzzle. The words may have been placed in one of the four directions as from (i) left to right (E), (ii) right to left (W), (iii) up...
6
by: Phoe6 | last post by:
Hi All, I would like to request a code and design review of one of my program. n-puzzle.py http://sarovar.org/snippet/detail.php?type=snippet&id=83 Its a N-puzzle problem solver ( Wikipedia page...
2
by: Gio | last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book? And while I'm there, should I get the Puzzle Book? Or should I save the Puzzle Book for when I'm more advanced? - Gio ...
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
5
by: dmf1207 | last post by:
Hi All! I'm new to javascript and need a little help with a simple puzzle im trying to design. I have a 600x100 pixel picture that I have sliced into 6 100x100 rectangles making a table of of 6...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.