some comments on sessions
- $PHPSESSID will only be set after the first page refresh.
- SID will only be set if your not using cookies.
- sessions with not transfer across multiple domain names.
- sessions without cookies will not transfer accross full urls.
<?php
if (isset($PHPSESSID))
session_start($PHPSESSID);
else
session_start();
$PHPSESSID = session_id();
$SID = "PHPSESSID=$PHPSESSID";
?>
use this code and
- sessions will transfer across full urls when using $SID
- sessions will transer across multiple domain names on the same server
using $SID
- both $PHPSESSID and $SID are set allways set.
remember that header redirects *require* full urls so you will have to use
$SID.
header("Location: http://$SERVER_NAME/index.php?$SID");
--
Chris Lee
Mediawaveonline.com
ph. 250.377.1095
ph. 250.376.2690
fx. 250.554.1120
[EMAIL PROTECTED]
""Jon Rosenberg"" <[EMAIL PROTECTED]> wrote in message
001301c09dc9$fc471c80$[EMAIL PROTECTED]">news:001301c09dc9$fc471c80$[EMAIL PROTECTED]...
> I have a form that submits to abc.php which then calls db.php and db.php
> then redirects to a new URL. I have session_start(); on all these files
and
> I'm registering the variables I need. It seems that the session dies or
> gets lost on it's way through all the included files. I then tried to
pass
> the SID in the URL that the db.php file creates, but the SID is empty once
> it gets here...though, there is a SID befoer then. Can sessions not be
used
> with multple include files? What could I be doing wrong? This is my
first
> forray into sessions...be gentle!
>
> thanks!
>
> Some code below, it's prettry straight forward. I still have cookies
> enabled, as well. Do I need to disable cookies for the SID in URL method
to
> work?
>
> index.php where they log in from
> <?
> session_start(); //first line of file
> ?>
> <form method="POST" action="main.php">
> <input type="hidden" value="lrlogin" name="form_action">
> Username <input type="text" name="username" class="color"><br
/>
> Password <input class="color" type="password"
name="password"><br
> />
> <input type="reset"> <input type="submit" value="Login">
>
> code from main.php
> <?
> session_register();
> require ("db.php");
> if $form_action == "lrlogin"
> {
> get_user($username,$password);
> }
> ?>
>
> code from db.php
> <?
> session_start();
> SQL to select user info from db
> $access = $row[access_level]; //etc getting vars from db
> session_register("username");
> session_register("password");
> session_register("access");
> session_register("active");
> header("Location:http://www.blah.com/index2.php?=".SID);
> exit;
> ?>
>
> index2.php code
> <?
> session_start();
>
> print "Welcome $username";
> ?>
>
> it only prints Welcome ...no username :(
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]