To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Upgrading PHP

Upgrading PHP Issues concerning PHP version upgrades and future releases

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-14-2004, 10:03 AM   #1
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
Session variable not registering

I'm testing an example script:
PHP Code:
<?php
session_start
();

// If session variable doesnt exist, register it
if ( !isset ( $_SESSION['test'] ) ) {
    
$_SESSION['test'] = 'Hello World!';
    echo (
'$_SESSION[\'test\'] is registered.<br />Please refresh page' );
} else {
    
// Its registered so display it
    
echo ( '$_SESSION[\'test\'] = '.$_SESSION['test'] );
}
?>
According to what I'm seeing and reading, the first time the page displays, I should get the following result (which I do):

$_SESSION['test'] is registered.
Please refresh page


Upon refreshing the browser, I should get (which I don't):

$_SESSION['test'] = Hello World!


When I refresh the browser, I end up getting the first result over and over again. What am I missing?

Thanks!
ywickham is offline   Reply With Quote
Old 08-14-2004, 10:58 AM   #2
yelvington
Senior Member
 
Join Date: Dec 2000
Location: USA
Posts: 1,012
Your example is not even parseable due to string quotation craziness -- please post your actual code.
yelvington is offline   Reply With Quote
Old 08-14-2004, 11:00 AM   #3
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
I'm trying to post the code, but I can't get the forum to show my escape slashes. When I edit the original forum post, the code is as it should be, but it is not appearing that way when displayed.

I will continue to try and get the forum to display my code correctly.

Last edited by ywickham; 08-14-2004 at 11:04 AM.
ywickham is offline   Reply With Quote
Old 08-14-2004, 11:15 AM   #4
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
Here is the code as I have it above (but is not displaying, for some reason):

<?php
session_start();

// If session variable doesnt exist, register it
if ( !isset ( $_SESSION['test'] ) ) {
$_SESSION['test'] = 'Hello World!';
echo ( '$_SESSION[\\'test\\'] is registered.<br />Please refresh page' );
} else {
// Its registered so display it
echo ( '$_SESSION[\\'test\\'] = '.$_SESSION['test'] );
}
?>
ywickham is offline   Reply With Quote
Old 08-14-2004, 11:53 AM   #5
yelvington
Senior Member
 
Join Date: Dec 2000
Location: USA
Posts: 1,012
I don't see anything that would cause a problem. I made a slightly different version

PHP Code:
<?php
    session_start
();

    
// If session variable doesnt exist, register it
    
if ( !isset ( $_SESSION['test'] ) ) {
        
$_SESSION['test'] = 'Hello World!';
        echo
$_SESSION['test'], ' is registered.<br />Please refresh page' ;
    } else {
        
// Its registered so display it
        
echo '$_SESSION[test] = ' , $_SESSION['test'];
    }
    
?>
and it worked just fine. So I would check to make certain that the session save path is correctly set in php.ini. PHP5 has a way of defaulting to nonsense, regardless of what the notes in php.ini might say. Be sure to set everything explicitly.
yelvington is offline   Reply With Quote
Old 08-14-2004, 12:00 PM   #6
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
Thank you for your help.

Someone else manages our server, so, are you saying that I basically need to ask them to make sure that whatever path is specified in the php.ini file for the "session.save_path" directive is a writeable directory? (Did that make sense? )
ywickham is offline   Reply With Quote
Old 08-14-2004, 12:11 PM   #7
yelvington
Senior Member
 
Join Date: Dec 2000
Location: USA
Posts: 1,012
That's correct.

When I upgraded to PHP5, I had to spend quite a bit of time tracking down little ini file incompatibilities like this.
yelvington is offline   Reply With Quote
Old 08-14-2004, 12:21 PM   #8
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
Thank you. I wanted to make sure I knew what I was talking about before I asked them to do it.

I appreciate all your help.
ywickham is offline   Reply With Quote
Old 08-16-2004, 10:24 AM   #9
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
I got a reply from our web host and it seems that I left out some pertinent information in this problem.

This PHP code is called as a SSI from an HTML page. I thought that including the file at the top of the HTML page, it would still pick up the session file. That doesn't look like the case.

If I'm calling the file from an SSI like above, is there any way to get the PHP files to pick up the session file with the variables?
ywickham is offline   Reply With Quote
Old 08-16-2004, 10:26 AM   #10
yelvington
Senior Member
 
Join Date: Dec 2000
Location: USA
Posts: 1,012
Does it process any PHP in the include?
yelvington is offline   Reply With Quote
Old 08-16-2004, 10:29 AM   #11
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
I'm going to say yes, it does, since it displays the output of the script as if it was the first time the page was loaded.
ywickham is offline   Reply With Quote
Old 08-17-2004, 11:54 AM   #12
ywickham
Senior Member
 
ywickham's Avatar
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 126
I'm closing this thread because my initial question has been answered and my remaining question has evolved into something else. I am opening a new thread.
ywickham is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:41 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.