PDA

View Full Version : SESSION In A Frame Ignored



tomyknoker
07-09-2007, 04:47 AM
I am working on a site which uses Frames ug! I have the following code on the top frame but the user logs in in the bottom frame so it's just ignored... And the browser acts as though the user hasn't logged in. If I put the code in the bottom frame it works, but it needs to stay in the top... Any one have any clues?


<?php
if ($_SESSION['LoggedIn'] == true)
{
?>
<a href="javascript:top.window.close()" onMouseOver="MM_swapImage('Image222','','images/log_out_1.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/log_out_0.gif" name="Image222" width="46" height="17" border="0" id="Image222"> </a>
<?
}
else
{
?>
<a href="javascript:top.window.close()" onMouseOver="MM_swapImage('Image1','','images/close_window_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/close_window_off.gif" name="Image1" width="94" height="17" border="0" id="Image1"> </a>
<?
}
?>

Twey
07-09-2007, 09:46 AM
The page in the frame is a separate request, so session_start() needs to be called from the pages in that frame. There's no way around it.

tomyknoker
07-09-2007, 12:33 PM
Hey Twey... So then how can I make the code in the top frame work?

alexjewell
07-09-2007, 02:05 PM
<?php session_start();

if ($_SESSION['LoggedIn'] == true){ ?>

<a href="javascript:top.window.close()" onMouseOver="MM_swapImage('Image222','','images/log_out_1.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/log_out_0.gif" name="Image222" width="46" height="17" border="0" id="Image222"></a>

<? }

else{ ?>

<a href="javascript:top.window.close()" onMouseOver="MM_swapImage('Image1','','images/close_window_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/close_window_off.gif" name="Image1" width="94" height="17" border="0" id="Image1"></a>

<? } ?>


And, if you want this to display that immediately after they log in, you might want to add some JavaScript in the bottom frame that will refresh the top once they log in...because the page needs to be refreshed to communicate with the server (unless you go with something along the lines of AJAX).

tomyknoker
07-10-2007, 01:09 PM
hey alex... well that works! but yes need to refresh the top frame to do it... do you know how to do this?

tomyknoker
07-16-2007, 10:47 AM
Anyone know how I could achieve this?

alexjewell
07-16-2007, 01:15 PM
I'm going to do some more research on this, but I think it may be something along the lines of the following JavaScript:



framename.location='something.html'


framename would be the name of the frame, and something.html would be the frame's address.

tomyknoker
07-16-2007, 01:18 PM
thanks for the help alex really appreciate it... so where would i put that code?

alexjewell
07-16-2007, 01:18 PM
Hmmm, if the above doesn't work, you could try:



parent.framename.location.reload()


EDIT: That code would be within script tags:



<script type="text/javascript">parent.framename.location.reload();</script>


And you would want to echo that after the user has logged in on the bottom frame.

djr33
07-16-2007, 02:06 PM
Or some type of request, such as <a href="#" onClick=".......">, onMouseover, onChange, onSubmit, etc etc.

alexjewell
07-16-2007, 02:20 PM
Sure, but he wants it to happen automatically after they log in.

tomyknoker
07-23-2007, 12:33 AM
Still can't get this thing to work... Ahhhh frames suck!

tomyknoker
07-25-2007, 01:05 AM
Anyone have any ideas?

alexjewell
07-25-2007, 01:11 PM
Get rid of frames. Ha.

tomyknoker
08-29-2007, 11:47 PM
Ha thanks Alex :) I really don't want to have to go down that road does anyone know ho to achieve this???