Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: SESSION In A Frame Ignored

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default SESSION In A Frame Ignored

    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 Code:
    <?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>
            <? 
            

            
    ?>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey Twey... So then how can I make the code in the top frame work?

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    PHP Code:
    <?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).
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey alex... well that works! but yes need to refresh the top frame to do it... do you know how to do this?

  6. #6
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone know how I could achieve this?

  7. #7
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    I'm going to do some more research on this, but I think it may be something along the lines of the following JavaScript:

    Code:
    framename.location='something.html'
    framename would be the name of the frame, and something.html would be the frame's address.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  8. #8
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for the help alex really appreciate it... so where would i put that code?

  9. #9
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Hmmm, if the above doesn't work, you could try:

    Code:
    parent.framename.location.reload()
    EDIT: That code would be within script tags:

    HTML Code:
    <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.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Or some type of request, such as <a href="#" onClick=".......">, onMouseover, onChange, onSubmit, etc etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •