LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-04-2009, 04:29 AM   #1
SangrelX
LQ Newbie
 
Registered: Jun 2009
Posts: 6

Rep: Reputation: 0
PHP - Pass Session to Iframe on same page


Ok guys ive been on this since 9pm and its now 5:30AM

I am stumped and after pouring over google I have no solved this issue

Situation:
the following is just for straight example so you guys can understand what I need


Page.php -- has a special division thats empty and on Link Click calls

Javascript to change inner.html to an IFRAME call

So the user clicks the link and then it shows the division and loads the IFRAME

The IFRAME Source is

iframe.php

in IFRAME.PHP I need to take the Session Variables that were set already in Page.php

all sessions work fine when not using Iframe (open iframe.php in its own window)

but doesnt work when its Iframed and sadly I have to use Iframe on this page


NOW the CATCH is -- I CANNOT use any POST or GET Values
the iframe src MUST be straight url to the page aka src="www.blah.com/iframe.php"

cannot use variables in the url www.blah.com/iframe.php?sessid=blah etc..


IS it possible to do what I need Without passing variables via the url?

RECAP
Page1 has all session variables set, calls the iframe command when users presses a button, Iframe loads but DOES not have the Session data that was saved on Page1 -- and IFRAME cannot pass variables via the URL it must be a direct url to the page only


Hope i have explained this enough -- Below are some Code Snipplets

Page1.php

java used to set the HTML / IFRAME into its Div

Code:
<script>
function changeText(){
	document.getElementById('iframediv').innerHTML = "<iframe scrolling='no' frameborder='0' margin='0' src='http://mypage.blah/iframe.php'></iframe>";
}
</script>
Code Snipplet from the iframe.php to get session variables FROM page1.php

Code:
$uid = $_SESSION["usersid"];
$postID = $_SESSION["postsid"];
$pid = $_SESSION["partnerid"];
$serverid = $_SESSION["serverid"];
$user_name = $_SESSION["username"];

Any help is appreciated very much guys..
Thanks
SangrelX
 
Old 10-05-2009, 04:20 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

The session id is stored in a browser cookie by default, and the browser will send it as long as the domain name is the same. Note that the www prefix can mess things up, since www.example.org is not the same as example.org. If the iframe is on a different domain name, you have to send the session id as a parameter.
 
Old 10-05-2009, 11:35 PM   #3
SangrelX
LQ Newbie
 
Registered: Jun 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Hi

The session id is stored in a browser cookie by default, and the browser will send it as long as the domain name is the same. Note that the www prefix can mess things up, since www.example.org is not the same as example.org. If the iframe is on a different domain name, you have to send the session id as a parameter.

Thank you for your input, I had solved this issue on my own. However you are correct - Part of my problem was indeed I had the URL set different No www. as opposed to the www. on the actual main page


Also I wanted to add some information for those who might also have a similiar problem

You will get Headers already sent errors if you place Echo commands for session_id and session_name

Most of my issues were because I was leaving those commands in place to make sure I did indeed transfer the session/cookies properly to the iframe and that was my fatal error - I was placing @ signs in front of the session call to ignore the errors when in fact those Errors where what was stopping the script from functioning


Since you were the only one who opted to help me out I will be adding A thank you to your account.

Thanks
SangrelX
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A virus changed all my index files with iframe, how to remove that iframe line? Farman Linux - Security 10 07-16-2009 08:40 AM
iframe worm or malware infected my php pages ddaas Linux - Security 4 05-22-2009 12:52 PM
force iframe content to remain in iframe? frieza Programming 1 09-17-2008 06:29 AM
embed table from nagios status page on differnet webpage with maybe iframe? sinbsd Programming 0 05-08-2008 12:57 PM
web page database access per page or per session? b0uncer Programming 6 01-13-2007 12:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration