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
https://forums.phpfreaks.com/topic/224503-sessions/
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
https://forums.phpfreaks.com/topic/224503-sessions/#findComment-1159691
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.