Jump to content

sessions


doddsey_65

Recommended Posts

i have an upload form and a posting form on the same page.

when you upload a file it is uploaded to the server. what i am then trying to do is add the name of the file to $_SESSION['attachment'] so i can use it later. When the user posts their form i want the session to be inserted into the database but the session always comes up empty.

 

this is what happens when they upload their file

Setting the session and moving the file:

session_start();
$_SESSION['attachment'] = "EXAMPLE";
move_uploaded_file($_FILES['Filedata']['tmp_name'], "../attachments/" . time() . $_FILES['Filedata']['name']);

 

and then when they submit their form(textarea) it uploads the contents to the database and the contents of the session aswell.

 

Why is this session always empty?

Link to comment
Share on other sites

have you got session_start(); at the top of every page using the session variables?, I can see on this bit of code you have but that doesnt show us much of how you are writing it anywhere else

what happens if you echo the session on the page you create it on after the move upload file bit?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.