468,458 Members | 1,748 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

Session variables through frames - need help.

Hi there,

I have implemented a login sequence using session variables for a PHP/MySQL
DB which I took over development. I read some books and this NG and it
seemed straight forward. However the website I have taken over uses two
frames. The left hand side is always a navigation frame with the righthand
side of the screen always being the target.

I developed a main web page where login takes place and if successful a
session variable is set which all other pages look for before processing (if
it's not there they redirect to login page).

All seems to work OK from my PC until I use another frame as a URL
redirection to the PHP website. Therefore I want to use a nicer URL to where
the actual PHP website is hosted and so set another website to use frame
redirection to my PHP website DB.

When I do this the login session variables no longer seem to work and I can
no longer stay logged in. I assume this is something to do with where the
actual session variables are being set but do not know enough to be sure.
What is the problem and is there an easy way around it?

Any help on this matter greatly appreciated.

Kind regards

Dave
Jul 17 '05 #1
1 2014
On Mon, 02 May 2005 22:58:21 +0100, Dave Smithz wrote:
Hi there,

I have implemented a login sequence using session variables for a PHP/MySQL
DB which I took over development. I read some books and this NG and it
seemed straight forward. However the website I have taken over uses two
frames. The left hand side is always a navigation frame with the righthand
side of the screen always being the target.

I developed a main web page where login takes place and if successful a
session variable is set which all other pages look for before processing (if
it's not there they redirect to login page).

All seems to work OK from my PC until I use another frame as a URL
redirection to the PHP website. Therefore I want to use a nicer URL to where
the actual PHP website is hosted and so set another website to use frame
redirection to my PHP website DB.

When I do this the login session variables no longer seem to work and I can
no longer stay logged in. I assume this is something to do with where the
actual session variables are being set but do not know enough to be sure.
What is the problem and is there an easy way around it?

Any help on this matter greatly appreciated.

Kind regards

Dave


I've played around with frames only a little, but am also using some
iframes and I think the situation is the same.

In a no-frames situation, you have your session_start() call somewhere on
each page's script, and since your browser sends the same session ID, your
session is continued, and your session variables are remembered, from page
request to page request.

In a frames situation, you can have the same thing happen. Each frame
calls its separate source URL. In this case, each of these source URL's
have to be php scripts, and they all have to call session_start()
somewhere at the top of the script.

Since your browser works in the same browser window when loading up
various frames, the browser sends the same session key, so if you do the
above, your session variables are accessible from all frames.

You can also have one frame read in a form on submit, collect the posted
values from $_POST and put them into $_SESSION, so that the posted form
values will be available to other frames.

Hope that helps.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Rolf Rosenquist | last post: by
2 posts views Thread by Bonj | last post: by
13 posts views Thread by Alexander Widera | last post: by
2 posts views Thread by Iwan Adler | last post: by
10 posts views Thread by stathisgotsis | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.