PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Dave_will
Forum Newbie
Posts: 5 Joined: Mon Sep 22, 2003 4:07 am
Location: UK
Post
by Dave_will » Fri Sep 26, 2003 5:59 am
Using PHP version 4.1.2
Running test.php & test2.php gives the following output.
Current page: A = Page A
Current page: Z =
Why isn't the $_session['current_page_z'] = "Page Z"; working?
I've checked all the documentation...
<?php
// test.php
session_start();
$current_page_a = "Page A";
session_register ("current_page_a");
$_session['current_page_z'] = "Page Z";
$_sid_value = "?" . SID;
?>
<A HREF="test2.php?<?php echo strip_tags (SID)?>">Click here</A>
============================================
<?php
// test2.php
session_start();
print("Current page: A = " . $current_page_a . "<br>");
print("Current page: Z = " . $_SESSION['current_page_b'] . "<br>");
?>
============================================
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Sep 26, 2003 6:39 am
PHP is case sensitive so $_session is a different variable to $_SESSION, you need to be using $_SESSION to get this to work.
Mac
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Sep 26, 2003 6:42 am
Another thing, session_register() doesn't tend to play nicely with $_SESSION, so if $_session was a typo when you posted in the forum it is likely that session_register() is preventing the $_SESSION array from functioning correctly.
Mac
Dave_will
Forum Newbie
Posts: 5 Joined: Mon Sep 22, 2003 4:07 am
Location: UK
Post
by Dave_will » Fri Sep 26, 2003 7:01 am
Many thanks... a case of me being really stupid
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Sep 26, 2003 7:10 am
In cases like these it would be nice if there was a level of error reporting at which PHP would give out errors like 'I see you've got $_session - do you perhaps mean $_SESSION', kinda like the way that Google keeps telling me I can't spell
.
Mac
AnsonM
Forum Commoner
Posts: 72 Joined: Thu Sep 25, 2003 7:21 am
Post
by AnsonM » Tue Sep 30, 2003 7:17 pm
isnt it
session_register("current_page_a"); ?
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Tue Sep 30, 2003 11:06 pm
haha, google's the best.
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Oct 01, 2003 3:23 am
AnsonM wrote: isnt it
session_register("current_page_a"); ?
Not any more, session_register() does not work with register_globals off and has been deprecated in favour of the:
method of setting session variables.
Mac