$_SESSION NOT TRANSFERED INTO IFRAME

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amer
Forum Newbie
Posts: 4
Joined: Wed May 26, 2004 9:49 am

$_SESSION NOT TRANSFERED INTO IFRAME

Post by amer »

Could anyone find solution and help me to understand the sitaution ?

Code: Select all

<?
session_start();
$_SESSION['x']="x";
session_register("register");
$register="y";
?>
<iframe src=x.php></iframe>

<? X.PHP
session_start();
$id=session_id();
print<<<end
$register $_SESSION['x'] $id 
end;
?>
the result of this code is:
y cb05f6258e0fcdcbdde750ab3af85845

so the registred variable $y and the session_id appears in iframe but not the variable $_SESSION['x']...

???

ps. aha in php.ini i got
session.use_trans_sid = 1
url_rewriter.tags=
"a=href,area=href,frame=src,input=src,form=fakeentry,iframe=src"
and register_globals = on
(if it may help...)
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Try to refresh the page after you have set the session data and see if it makes a difference.
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

There is some information in php manual http://fi.php.net/manual/en/function.se ... gister.php on session_register. There is caution not to use session_register if $_SESSION is being used. Don't know exactly why, but this misfunction you experienced might have something to do with this.
amer
Forum Newbie
Posts: 4
Joined: Wed May 26, 2004 9:49 am

Post by amer »

completely not; any difference made
amer
Forum Newbie
Posts: 4
Joined: Wed May 26, 2004 9:49 am

Post by amer »

no it is not about "caution not to use session_register if $_SESSION is being used"; i have use the session_register just to show that if it is used some variable come into iframe; without it there is the asme result;
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

you have "register_globals = on" does $x print? I believe it should.
amer
Forum Newbie
Posts: 4
Joined: Wed May 26, 2004 9:49 am

Post by amer »

yes, thanks very much - it is printing $x !!!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

You didn't have {} around your $_SESSION call. This would have worked:

Code: Select all

<? 
session_start();
$id=session_id();
print<<<end
$register {$_SESSION['x']} $id
end;
?>
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

Some information can be found at http://www.php.net/types.string The heredoc syntax you are using produces a string. And inside a string you should use $_SESSION[x] or for any array variable $arr[something] wihout quotation marks. But outside a string quotation marks has to be used unless you don't mind Notices of undefined constants. Or you could use braces as jason pointed.

Code: Select all

<?php
print $arr["something"];
print "$arr[something]";
print <<<end
$arr[something] or {$arr['something']}
end;
?>
But the mystery is not solved yet. Syntax $_SESSION['x'] should lead to parse error and in your case it does not?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

display_errors may be off... if it didn't show...
Post Reply