473,769 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.leftfram e 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 8549
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.leftfram e 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?PHPS ESSIONID=563245 62134) 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?PHPS ESSIONID=563245 62134) 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?PHPS ESSIONID=563245 62134) 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************ *************** *************** @spamyourself.c om> wrote in message news:<42******* *************** *@news.xs4all.n l>...

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************ *************** *************** @spamyourself.c om> wrote in
message news:<42******* *************** *@news.xs4all.n l>...

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
1847
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 frame display. The main page is called index.php and all of the named frames have matching file names with a ..php extension, running apache2triad1.1.9. I am trying to create a secure site for viewing a private user database management system for...
7
7534
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 including the php.net manual. In the manual it said to include something like the following:
12
2526
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 to store a logged in token. With only basic knowledge of sessions I assumed there was some kind of default time before the session data is destroyed. Is this the case?
1
1157
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 application keeps running seemingly eventhough pages catch for session-ending. Our intranet site has 4 frames running all the time. When a user signs into the site on one main page (no frames) the session is populated. When the 4 frames load up, are the...
4
3362
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 the browser, but we can't just simply copy the site and database over to to a new URL. My first thought was to set up a site at the new URL and then include the PHP site in a frame... but the PHP sessions prevent us from doing this.
41
3243
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 resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
1
1270
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 frame is not disappearing? is it means sessions are not expired in the above frame????? please help me that the login page has to be displayed in a new page............
3
1308
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 mainframe. I have put the session timeout period on each page so if some user remains inactive for 10 minutes, he will be redirected to logout.php page through header. Problem is that, the logout.php page will certainly be opening in mainframe,...
8
1841
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(). Program B is started by the user clicking on a link and it also calls session_start(). The session started by program B blows away the session started by program
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.