Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

PHP for Dummies (Me being the dummy)

 
   Database Forums (Home) -> PHP RSS
Next:  Corruption  
Author Message
rik

External


Since: Jul 21, 2005
Posts: 2



(Msg. 1) Posted: Fri Aug 05, 2005 8:18 am
Post subject: PHP for Dummies (Me being the dummy)
Archived from groups: comp>lang>php (more info?)

Maybe it is just cos it is Friday and my head is already gone away for
the weekend but I just cannot get sessions working!

Anyway - two pages. Page one starts session and registers a sesison
variable, Page 2 tries to then print out the session variable...

Sorry if its obvious but I have stripped down my previously working
code to just these few lines and still cannot fathom where the error
lies.

Simple. BUT IT WON'T WORK! PLEASE PUT ME OUT OF MY MISERY!

Page 1:
<?php
session_start();
session_register("test");
$_SESSION["test"] = "Hello World";
?>
<a href='check_test.php'>Check Test</a>


Page 2:
<?php
if ( session_is_registered("test") == true ) {
print "test is a registered session variable";
} else {
print "test is NOT a registered session variable";
}
?>

<br/>

<?php
print "test is " . $_SESSION["test"];
?>
<br />
<a href='set_test.php'>Set Test</a>




Thanks,

Rick

 >> Stay informed about: PHP for Dummies (Me being the dummy) 
Back to top
Login to vote
Ken Robinson1

External


Since: Sep 28, 2004
Posts: 13



(Msg. 2) Posted: Fri Aug 05, 2005 8:30 am
Post subject: Re: PHP for Dummies (Me being the dummy) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

rik wrote:
> Maybe it is just cos it is Friday and my head is already gone away for
> the weekend but I just cannot get sessions working!
>
> Anyway - two pages. Page one starts session and registers a sesison
> variable, Page 2 tries to then print out the session variable...
>
> Sorry if its obvious but I have stripped down my previously working
> code to just these few lines and still cannot fathom where the error
> lies.
>
> Simple. BUT IT WON'T WORK! PLEASE PUT ME OUT OF MY MISERY!
>
> Page 1:
> <?php
> session_start();
> session_register("test");

Do not use session_register( when you use session_start()

> $_SESSION["test"] = "Hello World";
> ?>
> <a href='check_test.php'>Check Test</a>
>
>
> Page 2:
> <?php

You need to use session_start() in each script where you want to use
Sessions.

> if ( session_is_registered("test") == true ) {

Here you should use

if (isset($_SESSION['test']))

> print "test is a registered session variable";
> } else {
> print "test is NOT a registered session variable";
> }
> ?>
>

Ken

 >> Stay informed about: PHP for Dummies (Me being the dummy) 
Back to top
Login to vote
rik

External


Since: Jul 21, 2005
Posts: 2



(Msg. 3) Posted: Fri Aug 05, 2005 9:01 am
Post subject: Re: PHP for Dummies (Me being the dummy) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Ken, you are a beautiful, beautiful man.

I, am a stupid, stupid man.

Regards,

Rick
 >> Stay informed about: PHP for Dummies (Me being the dummy) 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]