Michael Satterwhite <mi*****************@weblore.com> wrote in
news:02******************@fe2.texas.rr.com:
OK, I'll admit I've been doing it wrong (using session_register()), so
I'm trying to correct my ways, but...
My script starts with
<?php
session_start();
?>
In the body of my page a link as follows:
<a href="targetUrl.php?<php print SID; ?>">Target text</a>
Problem: SID is an empty string. I even tried
echo "SID: " . SID . '<br />';
and SID echoes as an empty string. Why?
Because you have cookies enabled, and are accepting
a cookie from your domain with the PHP page, and using
a browser that supports cookies ;-)
Do yourself a favour and use the Firefox browser, and
get the LiveHTTPHeaders extension. You can then see
the 'HTTP conversation' between your browser and the
server, and you'll see the session cookie being set,
and returned.
http://www.php.net/manual/en/ref.session.php
Predefined Constants
--------------------
SID (string)
Constant containing either the session name and session ID in
the form of "name=ID" or empty string if session ID was set in
an appropriate session cookie.
Passing the Session ID
----------------------
Alternatively, you can use the constant SID which is always defined.
If the client did not send an appropriate session cookie, it has the
form session_name=session_id. Otherwise, it expands to an empty string.
Thus, you can embed it unconditionally into URLs.
--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website:
http://members.shaw.ca/davepatton/