Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHPSESSID not working???

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
I am having trouble sending PHPSESSID through the URL.
Here is my code...

<?php
session_start();
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

echo '<br /><a href="page2.php?PHPSESSID=$_PHPSESSID">PAGE 2</a>';
?>

When I click "PAGE2" it obviuosly sends me to page 2, but in the URL it reads "page2.php?PHPSESSID=$PHPSESSID" Should $PHPSESSID not be a number??? I need this number because I am sending the session ID to another domain.

Thanks for your help
James
 
The URL looks like this when using your code...

page2.php?PHPSESSID=

There is nothing after the =

Note: If I type
echo"$PHPSESSID"; on my page I do get a number. But for some strange reason it will not send through the URL. Any other ideas?
 
nonono...

<a href="page2.php?<?=SID?>" title="page two">page two</a>

why reinvent the wheel?
ps. you only need to pass SID like this, if the user for some reason does not accept SID-cookies.

Olav Alexander Mjelde
Admin & Webmaster
 
Great, it goes through the url now! Thanks Muchly. One other problem.... Page 2 is on a different domain - so how do I Make that domains ID the same as page 1?

I tried this with no luck

$PHPSESSID = $_GET[PHPSESSID];

when echo-ing $PHPSESSID it is right -BUT - When trying to echo my session variables ex...

echo $_SESSION['animal'];

I get nothing.

PS - Thanks for the help guy:)
 
then you have to pass the variables in querystring, not session. The session variables are stored on the server, not in the client!

only the session-id is stored in the client.

<a href="www.domain2.tld/page2.php?variable1=<?=$_SESSION['variable1']?>">page2</a>

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top