• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

popup to upload file and set session values?

I would like to use a popup to upload a file and then to also
set $_SESSION values. These values should be saved after the
popup closes so that they can be used to fill fields in the main page.
The  popup, below, is not saving the $_SESSION values.
How can this be fixed?

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 if(!empty($_FILES) ){
echo  $_SESSION['name']; //for testing


<script language="javascript" type="text/javascript">

function popitup(url) {
      if (window.focus) {newwindow.focus()}
      return false;


<input type="file" name="in_file" id="in_file">
<input type="submit" name="submit">

1 Solution
Chris HarteThaumaturgeCommented:
Even though it is a popup, it is still a separate page. You need to include the function session_start() as the first line of php in every page.

Ray PaseurCommented:
This script will not work, even if you put session_start() at the top of the PHP because it has the HTML wrapper above the start-PHP statement. That creates browser output.  Browser output cannot come before cookies.  The session handler uses cookies. Thud.

Can you describe your question in non-technical terms?  It seems like there may be a standard design pattern that will meet your needs, but it's kind of hard to understand from what I have seen so far.

Thanks and regards, ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now