-2

Basically I am aware that you can make temporary file (lets call it file2) with the tempnam function in PHP. However, i was wondering how they could automatically be deleted when the user leaves the site. Or even better have that temp file be stored for that user and identified through a cookie.

I manually made a blank text file on which when a user drags an item into a basket that specific pathname for the item is added to the text file however, how do i make this occur for a temporary file which is automatically created when the unique user enters the site. I have a basic template on the site to help grasp your heads around the idea. However, of cource its not functioning properly at the moment as I have left some parts out.

Roy
  • 3,027
  • 4
  • 29
  • 43
  • 1
    Use sessions, and delete the file when the session expires. Sessions are (typically) associated to users by a cookie. – nickb Aug 23 '12 at 14:16

1 Answers1

2

Why not sessions?

session_start();

$_SESSION['basket'] = "Whatever you like";

php.net/Sessions

Peter
  • 16,453
  • 8
  • 51
  • 77