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 778239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:43:59+00:00 2026-05-14T19:43:59+00:00

I have the following pages: page1.php, page2.php and page3.php. Code in each of them

  • 0

I have the following pages: page1.php, page2.php and page3.php. Code in each of them is as below

CODE:

page1.php

<script type="text/javascript">

$(function(){
    $('#imgID').upload({
        submit_to_url: "page2.php",
        file_name: 'myfile1',
        description : "Image",
        limit : 1,      
        file_types : "*.jpg",

    })
}); 

</script>

<body>
<form action="page3.php" method="post" enctype="multipart/form-data" name="frm1" id="frm1">
//Some other text fields
  <input type="submit" name="submit" id="submit" value="Submit" />
</form>

</body>

page2.php

<?php session_start();
$a = $_SESSION['a'];
$b = $_SESSION['b'];
$c = $_SESSION['c'];

$res = mysql_query("SELECT col FROM table WHERE col1 = $a AND col2 = $b AND col3 = $c LIMIT 1");
$num_rows = mysql_num_rows($res);
echo $num_rows; //echos 0 when in fact it should have been 1 because the data in the Session exists.

//Ok let's proceed further
//... Do some stuff...
//Store some more values and create new session variables (and assume that page1.php is going to be able to use it)
$_SESSION['d'] = 'd';
$_SESSION['e'] = 'e';
$_SESSION['f'] = 'f';

if (move_uploaded_file($_FILES['file']['tmp_name'], $file)) 
{ 
  echo "success"; 
} 
else 
{
 echo "error ".$_FILES['file']['error'];
}

?>

page3.php

<?php session_start(); 
if( isset($_POST['submit']) )
{
  //These sessions are non-existent although the AJAX request 
  //to page2.php may have created them when called via AJAX from within page1.php 
  echo $_SESSION['d'].$_SESSION['e'].$_SESSION['f']; ?> 
}
?>
  1. As the code says it I am posting some info via AJAX call from page1.php to page2.php. page2.php is supposed to be able to use the session values from page1.php i.e. $_SESSION[‘a’], $_SESSION[‘b’] and $_SESSION[‘c’] but it does not. Why? How can I fix this?

  2. page2.php is creating some more sessions after some processing is done and a response is sent back to page1.php. The submit button of the form on page1.php is hit and the page gets POST’ed to page3.php. But when the SESSION info that gets created in page2.php is echoed, it’s blank signifying that SESSIONS from page2.php are not used. How can I fix this?

I looked over a lot of information and have spent about 50 hours trying to do different things with my scripts before arriving at the above conclusions. My app. is custom made using function (not OOPS) and does not use any PHP frameworks & I am not even about to use any as my knowledge of OOP concepts is limited any many frameworks are object oriented. I came across race conditions, but the solutions provided don’t help too much. One more solution of using DB to hold sessions and seek and retrieve from DB is the last thing on my mind and I really want to avoid creating table, coding and maintaining code for a task as simple as just keeping sessions across pages in the same domain.

So my request is: Is there a way that I can solve the above problem(s) via simple coding in present conditions? Any help is appreciated.

Thank you.

EDIT:
Also I have sensitive information contained in the SESSIONS that I cannot pass back and forth via the pages using GET or POST. So using SESSIONS is really helpful for me. So if any coding can help me achieve this, that would be really helpful. Thanks.

  • 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-14T19:43:59+00:00Added an answer on May 14, 2026 at 7:43 pm

    From the SWFUpload documentation:

    Cookie issue

    On Windows the Non-IE Flash Player
    plugin (FireFox, Opera, Safari, etc)
    will send the IE cookies regardless of
    the browser used. This breaks
    authentication and sessions for many
    server-side scripting technologies.

    Developers should manually pass
    Session and Authentication cookie
    information and manually restore
    Sessions on the Server Side if they
    wish to use Sessions

    The SWFUpload package contains
    work-around sample code for PHP and
    ASP.Net

    I suspect SWFUpload causes your problem.

    Check if your javascript posts the session_id:

    new SWFUpload({
       ...
       post_params: {
         "PHPSESSID" : "<?php echo session_id(); ?>"
       }
    }
    

    And if your PHP script reacts to the sent session_id.

    if (isset($_POST["PHPSESSID"])) {
        session_id($_POST["PHPSESSID"]);
    }
    session_start();
    

    (session.auto_start should be disabled in your php.ini or .htaccess)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Firefox 3.6.6. I have a PHP script called index.php with the following
I have the following jQuery code which runs when I'm clicking an option in
I have a medium size legacy php application with almost no javascript integration. I've
I have following code: SELECT q21, q21coding AS Description FROM `tresults_acme` WHERE q21 IS
The first line of code, called on every one of my application's pages, is:
I have a table with the following structure. I cannot seem to get the
I am building a PHP registration form which takes the following fields for up
I have numerous domains and rather than create content for each one individually, I'm
I've always found that defining URLs for other pages in a Web Application seems
I am a PHP developer and in one of my projects, I need to

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.