Reply to SESSION puzzle

Your name:

Reply:


Posted by Tom on 12/29/05 02:23

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:
kernbuild@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'].

[Back to original 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

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