on 25/10/02 6:38 AM, Bryan McLemore ([EMAIL PROTECTED]) wrote:

> Hi guys I'm a little confused on how sessions work.  ok I  use
> session_start(); to get started I know that but then the manual starts to
> confuse me with all of the garbled text about passing the SID.  How do I tell
> if it was compiled with transparent SID passing?

make a <? phpinfo() ?> file -- it will explain what PHP was compiled with up
the top-ish.


> Also I'm not sure how to use cookies and this is just a small application for
> private use so I don't mind passing it using urls for this iteration of the
> project.  

By default, sessions will work with cookies (at least every install i've
seen)... you don't need to do anything special to get it working.  *IF* you
are worried about people without cookies not being able to maintain the
session, *THEN* passing the SID around in URLs would be the next step.  You
can do this manually (a lot of work), or...

*IF* enable_trans_sid() was compiled (or if you can comile with it), this is
the best option, because everything happens transparently... IF the user
allows cookies, PHP will use them... if not, PHP will re-write your URLs
with the SID in them.

Easy.



> Also I'm not quite sure how to auctually perserve the variables across pages.

Assuming PHP >= 4.1.1 with register globals OFF, and cookies ALLOWED by your
browser OR trans_sid compiled:

page 1:

<?
// maintain or start session
   session_start();
// assign a few variables to it
   $_SESSION['favcolor'] = "#FFCC99";
   $_SESSION['name'] = "Justin";
?>
<HTML>
   <BODY>
      <A HREF="page2.php">click here to see page 2</a>
   </BODY>
</HTML>


page 2:

<?
// maintain or start session
session_start();
?>
<HTML>
   <BODY bgcolor="<?=$_SESSION['favcolor']?>">
      Hi <?=$_SESSION['name']?>, hopefully this session carried forward.<BR>
      <A HREF="page3.php">click here to see it carried to page 3</a>
   </BODY>
</HTML>


page 3:

<?
// maintain or start session
session_start();
?>
<HTML>
   <BODY bgcolor="<?=$_SESSION['favcolor']?>">
      Hi <?=$_SESSION['name']?>, hopefully this session carried forward to
the third page.
   </BODY>
</HTML>


Good luck,


Justin French


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to