Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:38:29+00:00 2026-05-28T02:38:29+00:00

delete_define.php has the following code snippet: <?php session_start(); ?> <form action=delete_now.php target=upload_target onsubmit=return my_func_1();>

  • 0

delete_define.php has the following code snippet:

<?php
    session_start();
?>

<form action="delete_now.php" target="upload_target"  onsubmit="return my_func_1();">
    <input type="submit" name="my_submit" class="my_submit" value="submit"/>
    <iframe id="upload_target" name="upload_target" src1111="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
</form>

<script type="text/javascript">
    function my_func_1(){
       //alert("from within my_func() =" +<?php echo $_SESSION['my_session'];  ?>);
       alert(" my_func_1");
       return true;
    }

    function my_func_2(){
       alert("my_func_2 =" +<?php echo $_SESSION['my_session'];  ?>);
       return true;
    }
</script>

delete_now.php has:

<?php
    session_start();
    $_SESSION['my_session']=rand();
?>

<script type="text/javascript">   
    alert("from within delete_now.php = " +<?php echo $_SESSION['my_session'];  ?>);
    window.top.window.my_func_2();
</script>

The problem is my_func_2() does not give the same output for the session variable as the alert box in delete_now.php gives.

Why is that?

EDIT: CHANGED THE CODE SAID TO BE IN delete_define.php
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:38:30+00:00Added an answer on May 28, 2026 at 2:38 am

    That’s because when the delete_define.php was loading the Session var was one, then it’s become another, but in you JS stored previous value.

    You should store session var into JS var, and then in JS in delete_now.php reset it with the fresh value.

    How to refresh value from frame and other situations

    Add to first php file’s JS something like:

    var session_var = '<?php echo $_SESSION['my_session']; ?>';
    

    And then in your delete_now.php’s JS:

    parent.session_var = '<?php echo $_SESSION['my_session']; ?>';
    

    And change function my_func to alert session_var JS variable.

    Think so…

    Explanation:

    Then result page js will be:

    function my_func_2(){
       alert("my_func_2 = 13513513513513");
       return true;
    }
    

    So when you call it, whatever is in the $_SESSION is, there will be old, static value.

    Overall process description:

    1. Load delete_define.php
    2. Javascript var, containing actual filename initialized
    3. From submits
    4. Script delete_now.php is runing
    5. Javascript var in main window refreshes
    6. You call my_func_2() which use you global JS var, containing fresh filename.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

html in delete_define.php follows: <form action=delete_now.php onsubmit=my_funct();> <input type=submit name=my_submit class=my_submit value=submit/> </form> javascript
I wrote the following pre-commit script for SVN to validate that a user has
I am using PHP to process a form and handle errors. The errors work
For my favorite modes, I use the following snippet to load hs-minor-mode on startup:
There seems to be a problem with the code I have for calling php
This is follow up post where I'm having a problem where my php code
The tag of the following PHP echo statement is not displayed by the browser
I have some PHP 5.3 code which builds an array to be passed to
$(.delete).click( function() { var thesender = this; $(thesender).text(Del...); $.getJSON(ajax.php, {}, function(data) { if (data[result])
I want to redirect m.example.com to example.com/index.php?type=mobile while inheriting the rules I've already written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.