Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-11-2007, 09:23 PM   PM User | #1
Leeoniya
Regular Coder

 
Join Date: Apr 2006
Location: Northbrook, IL
Posts: 388
Thanks: 8
Thanked 6 Times in 6 Posts
Leeoniya is on a distinguished road
Question session_register help plz.

PHP Code:
session_start();

if (!isset(
$_SESSION['pears'])) {
    echo 
"pears were not set";
    
session_register ("pears");
    
$pears dmondindex("pear");
}

if (!isset(
$_SESSION['pears'])) {
    echo 
"rounds were not set";
    
session_register ("rounds");
    
$rounds dmondindex("round");

dmondindex is a fairly lengthy parsing function that only needs to be done once per session. the above code doesn't seem to set the session variables properly because every time i refresh my browser i get the echo messages, instead of just the first time around

thanks,
Leon
Leeoniya is offline   Reply With Quote
Old 06-11-2007, 09:45 PM   PM User | #2
Sayonara
Regular Coder

 
Sayonara's Avatar
 
Join Date: Oct 2004
Location: UK
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Sayonara is an unknown quantity at this point
It looks like register_globals might be turned off on your server (this has been the default setting since PHP 4.2.0, and it is removed altogether in version 6).

You should instead use the $_SESSION array:
http://uk.php.net/manual/en/reserved...iables.session
__________________
Quote:
Originally Posted by liorean
Just remember that you code for the user, and the user visits you because what you code is good.
Sayonara is offline   Reply With Quote
Old 06-11-2007, 09:49 PM   PM User | #3
Leeoniya
Regular Coder

 
Join Date: Apr 2006
Location: Northbrook, IL
Posts: 388
Thanks: 8
Thanked 6 Times in 6 Posts
Leeoniya is on a distinguished road
yep already solved. thanks.

PHP Code:
session_start();

if (!isset(
$_SESSION['pears'])) {
    
$_SESSION['pears'] = dmondindex("pear");
}

if (!isset(
$_SESSION['rounds'])) {
    
$_SESSION['rounds'] = dmondindex("round");
}

$pears $_SESSION['pears'];
$rounds $_SESSION['rounds']; 
Leeoniya is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:38 AM.


Advertisement
Log in to turn off these ads.