Uno Mein Ame
Uno Mein Ame

Reputation: 1090

Retain $_SESSION while working with IFRAMEs

I have googled this extensively and am still not sure I fully understand the answer.

Is it possible to retain $_SESSION variables throughout several calls of a .php file from the same server into an iframe? The .php file gets called by way of POST form submission and gets opened inside an iframe.

The .php file ALSO needs to share the same $_SESSION variables.

The general idea is this - unless a user is logged in ($_SESSION['userLoggedIn'] and $_SESSION['userName'], the user should neither see the interface HTML, nor the .php file in the iframe.

Right now, as soon as I post the form into the php file in the iframe, the session is lost. And so I get the authorization login inside the iframe.

2 questions:

  1. Can this be worked out with IFRAMEs?
  2. If not, what is the best way to deal with it?

Upvotes: 0

Views: 837

Answers (1)

Indranil
Indranil

Reputation: 2471

Yes it can be worked within iframes if they're within the same domain. Make sure you do a session_start() on the iframe pages.

Upvotes: 1

Related Questions