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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing session variable to new _blank window

Status
Not open for further replies.

gizmicek

Programmer
Jun 25, 2003
107
CZ
Hi guys,
I'm facing a little problem now because I need to pass a session to the new _blank window opened using
Code:
<A href=&quot;something&quot; target=&quot;_blank&quot;>

I'm making chat window which should be opened in new window and still should have the session variable containing username available. It doesn't work even when I'm passing the session ID through the GET method to the new window.

I know that it can be done using cookies or the POST html method but I would like rather read the username from session variable since the sessions provide us with more security.

Any suggestion or help will be appreciated
 
The session should be available in the newly opened window. How are you verifying that it's not working?

//Daniel
 
Interesting, works fine in Mozilla, busted in IE. The simple version without passing the id that is.

Sessions are hands down the biggest differences in the two browsers, each frustrating in their own way.

I'd be curious to see how you're testing with the ID being passed and perhaps we can help look into it more... here's the simple test for anyone curious

Code:
test.php
<?php
session_start();

$_SESSION['bar']=&quot;foo&quot;;

echo '<a href=&quot;test2.php&quot; target=&quot;new&quot;>Click</a>';
?>

test2.php
<?php
session_start();

echo '<pre>';
print_r($_SESSION);

?>

Running on an XP Home, Apache 1.3.x, PHP 4.3.2

-Rob
 
Hi danielhozac & skiflyer,

I have main webpage where I have stored the user name in session variable $_SESSION['auth_user']. When I create a link on that page like this:

Code:
<A href=&quot;aa.php&quot; target=&quot;_blank&quot;>aaa</A>

and have aa.php like this:

<?php echo $_SESSION['auth_user'] ?>

I got absolutely blank page. Oh, now I see that I'm not starting the session on the blank page. That will most likely be the main problem. I almost forgot that no session mechanism is available if session_start() is not present at the top of the code. Well, thanks a lot for the hint. Now I have another question:

Will the session variable be available also in particular frames if my aa.php contains frames (assuming that all frames will start the session on the top of the page)?

Thanks guys
 
I went through quite some hassle with sessions in frames about a year ago... in fact if you search the forum you can probably still find the threads.

Long and short of it is, it does work, but you're going to be tinkering a fair bit, but you'll get it.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top