473,418 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

PHP Sessions in frames....

Hey all,

I have a website, which uses frames (I know, I know...). Left frame is
a navbar, with the main content in the right frame.

I can login using sessions on the right frame, giving "Thankyou, $name
(where $session(name) = $name etc - not got code available atm, so
thats not exactly right, but you get the gist...)

I use <body onLoad parent.leftframe etc to reload the left frame, which
checks to see if $name is blank, if it is, it displays a login link, if
its got text in, it displays "You are logged in as $name".....

Except I can't get my left frame to recognise that there is something
in $name, so it always displays the login link...

Am I missing something, or is there a limitation in php sessions with
regards to frames...

Thanks,
Ben

Jul 17 '05 #1
6 8531
BWGames wrote:
Hey all,

I have a website, which uses frames (I know, I know...). Left frame is
a navbar, with the main content in the right frame.

I can login using sessions on the right frame, giving "Thankyou, $name
(where $session(name) = $name etc - not got code available atm, so
thats not exactly right, but you get the gist...)

I use <body onLoad parent.leftframe etc to reload the left frame, which
checks to see if $name is blank, if it is, it displays a login link, if
its got text in, it displays "You are logged in as $name".....

Except I can't get my left frame to recognise that there is something
in $name, so it always displays the login link...

Am I missing something, or is there a limitation in php sessions with
regards to frames...

PHP doesn't even know about your frames.
It receives a cookie (or get: script.pgp?PHPSESSIONID=56324562134) and
retrieves the session based on that value.

SO If you are using cookies, you should be fine.
If you use URL-rewritting, be sure that you send the right SESSIONID in each
request.
Also be sure to read through php.ini: find the SESSION-section and see if
PHP is allowed to do the rewriting for you.

Another problem can be that the pages you display in the frames are from
different domains. Then NO cookie can be shared (luckily).

Regards,
Erwin Moller

PS: To hunt down bugs like this one, be sure you just check the browsers
cookies, delete them, see what PHP sets, etc. etc.

Thanks,
Ben


Jul 17 '05 #2
On Wed, 02 Feb 2005 12:25:09 +0100, Erwin Moller wrote:


PHP doesn't even know about your frames.
It receives a cookie (or get: script.pgp?PHPSESSIONID=56324562134) and
retrieves the session based on that value.
Am using cookies....
Another problem can be that the pages you display in the frames are from
different domains. Then NO cookie can be shared (luckily).
Same domain
PS: To hunt down bugs like this one, be sure you just check the browsers
cookies, delete them, see what PHP sets, etc. etc.


PHP sets the cookies alright... Has PHPSESSID and a hash.

After some more investigation, my sessions don't work at all regardles of
the frames... I just recently upgraded to PHP 4.3.10 from 4.1 though...

Setup is:

Standard form, with a name textfield defined. POSTs to a php script which
starts with
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$name = $_REQUEST['name'];
$_SESSION['name'] = $name;
?>
.....
<p>You are now logged in, <strong><? echo $name; ?></strong>! Use
one of the links on the left. </p>
<p><a href="test3.php">Test!</a></p>

echo $name displays it fine.

Clicking the test3.php link goes to

<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$_SESSION['name'] = $name;
?>
.....
<? echo $name; ?>

Yet, echo $name doesn't show anything....

Any ideas?

Thanks,
Ben

--
BWGames
to email change de.news to de-news
Jul 17 '05 #3
BWGames wrote:
On Wed, 02 Feb 2005 12:25:09 +0100, Erwin Moller wrote:


PHP doesn't even know about your frames.
It receives a cookie (or get: script.pgp?PHPSESSIONID=56324562134) and
retrieves the session based on that value.
Am using cookies....

Another problem can be that the pages you display in the frames are from
different domains. Then NO cookie can be shared (luckily).

Same domain
PS: To hunt down bugs like this one, be sure you just check the browsers
cookies, delete them, see what PHP sets, etc. etc.


PHP sets the cookies alright... Has PHPSESSID and a hash.

After some more investigation, my sessions don't work at all regardles of
the frames... I just recently upgraded to PHP 4.3.10 from 4.1 though...

Setup is:

Standard form, with a name textfield defined. POSTs to a php script which
starts with
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$name = $_REQUEST['name'];


I would strongly suggest you do not use $_REQUEST.
It scans $_GET, $_POST $_COOKIE for the requested name.
You have too little control where your info comes from.
Just use $_GET["somename"] or $_POST["somename"].

$_SESSION['name'] = $name;
?>
....
<p>You are now logged in, <strong><? echo $name; ?></strong>! Use
one of the links on the left. </p>
<p><a href="test3.php">Test!</a></p>

echo $name displays it fine.

Clicking the test3.php link goes to

<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$_SESSION['name'] = $name;
This is wrong.

This script doesn't KNOW $name.
SO you assign nothing to $_SESSION["name"]

You better put your errormessages ALL on (Also notices).
Then PHP would complain that $name is unknown...

You probably ment:

$name = $_SESSION['name'];
?>
....
<? echo $name; ?>

Yet, echo $name doesn't show anything....

Any ideas?

Thanks,
Ben

Regards,
Erwin Moller
Jul 17 '05 #4
Erwin Moller <si******************************************@spam yourself.com> wrote in message news:<42***********************@news.xs4all.nl>...

Another problem can be that the pages you display in the frames are from
different domains. Then NO cookie can be shared (luckily).

Thats my problem.

With firefox it is working fine, but I.E is starting a new session on
every page of the content frame. So nothing can be stored at all.

So I am a little bit clueless what to do.

Erwin are you still here?
Jul 17 '05 #5
NC
BWGames wrote:

Setup is:

Standard form, with a name textfield defined. POSTs to a php
script which starts with
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$name = $_REQUEST['name'];
$_SESSION['name'] = $name;
?>
....
<p>You are now logged in, <strong><? echo $name; ?></strong>! Use
one of the links on the left. </p>
<p><a href="test3.php">Test!</a></p>

echo $name displays it fine.

Clicking the test3.php link goes to

<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$_SESSION['name'] = $name;
?>
....
<? echo $name; ?>

Yet, echo $name doesn't show anything....


Of course it doesn't. You overwrite $_SESSION['name'] with
a yet-undefined $name. Replace this:

$_SESSION['name'] = $name;

with this:

$name = $_SESSION['name'];

Cheers,
NC

Jul 17 '05 #6
stefan wrote:
Erwin Moller
<si******************************************@spam yourself.com> wrote in
message news:<42***********************@news.xs4all.nl>...

Another problem can be that the pages you display in the frames are from
different domains. Then NO cookie can be shared (luckily).

Thats my problem.

With firefox it is working fine, but I.E is starting a new session on
every page of the content frame. So nothing can be stored at all.

So I am a little bit clueless what to do.

Erwin are you still here?


Erm, yes, I am now. :P
Bit late maybe.
Been very busy.

If you are still stuck, repost here, ok?

Regards,
Erwin Moller
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rick Langschultz | last post by:
I am wondering if I can use sessions in a site that utilizes frames? There is a "header", "footer","navigation_page" and "main" frame, they are the names of the frames and they are a typical 4...
7
by: John | last post by:
Hello. I want to get this blasted .htaccess file sorted out, so I can have sessions without register_globals being on. I have looked everywhere for info on this and I mean everywhere...
12
by: Dave Smithz | last post by:
Hi there, Users of my PHP DB application have complained that it seems to log them out every now and then. I actually assume this is when it has been idle for sometime as I use session variables...
1
by: Christopher | last post by:
Hello, I currently use session variables to store some basic values on an intranet site internally. However, sometimes those session values do not come through and other time sthey do yet the...
4
by: news | last post by:
We have a huge PHP e-commerce site that relies totally on PHP sessions and cookies. We need to create a demo version of the site for potential clients to use that does NOT show the original URL in...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
1
by: chowdary | last post by:
hi, iam using frames in my website, there are 2 frames in site. when sessions are expired the login page is displaying in the main frame, but the other frame as it is in above. why the above...
3
by: chowdary | last post by:
hi, I am using frames in my website,main application links are present on the top of page above mainframe, in main window. These links have target=mainframe, thus opening respective pages in...
8
by: Dave | last post by:
Hopefully this is an easy question for those with more experience. I have two separate programs that I want to use together on a website Program A starts first and calls session_start(). ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.