Forum Moderators: coopster

Message Too Old, No Replies

Sessions & Temp files

duplicates & unlinking/unregistering

         

tomda

7:29 am on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



2/ Sessions

Is there a way to unregistered a session variable when click on a link or submit a form?

I am tired to add a session_unregister command at the beginning of everypage everytime I am adding a new session variable. May be removing uneeded session var is not a must for improvment of server's speed and I should not unregister uneeded session variable?

****************************
3/ Temp files
I am using the GD library and it works this way :
a) Submit file
b) Copy the large and small pictures in the tmp file.
c) Show preview of the pic and an other form (title, descripton and keywords to tag the pic)
d) If data are correct, the two pics are copied in their respective directory and there are unlink in the tmp file using unlink().

Now, the problem start when the visitor click refresh on before data are approved -> this duplicates the pics in the tmp file and they have different names! So, well I am unlink() them, the duplicates are not deleted and stay in the tmp file.

Is there a way so that visitor do not refresh the page (using javascript) or it doesn't duplicate the pic when refresh is clicked (using php/GD function)?
I though I could compare file size (Kb and px) and check for similarity - if similarity found, it doesn't copy again?

Thanks
Tomda

Thanks for your help

jatar_k

4:26 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



2. for sessions it is recommended to use

unset($_SESSION['varname']);

for a single variable in the session and

session_unset();

to release the session all together.

3. maybe try changing your logic a little then.

a) Submit file to seperate script
b) Copy the large and small pictures into a destination dir
c) redirect to the second form
d) Show preview of the pic and an other form (title, descripton and keywords to tag the pic)
e) If data are correct, the two pics are copied in their respective directory and there are unlink in the tmp file using unlink().

If you unplug the ability to refresh the script that copies/creates the images then when they refresh the second form it won't do anything. Having the processing as part of the script is where you get refresh problems. This may make some extra programming but will save a lot of hassle in the long run.

I always think that it is a bad plan to have processing and display in the same script all the time. It makes browser refresh a problem. I try to unplug the actuall processing and put it into a seperate script that contains no output. Then the back button and refresh do not cause things to be re-processed.

tomda

6:11 am on Apr 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jatar_k,

Regarding the session, I usually used unset($_SESSION['varname']); as recommended but I wanted to know if it is possible to unset the session variable when clicking on a button in a form or when clicking on the link (that is using the onclick action).

Regarding the GD_library, indeed I changed it this weekend and it is just the way you describre it ;)

a) Submit file to seperate script
b) Copy the large and small pictures into a destination dir
c) redirect to the second form
d) Show preview of the pic and an other form (title, descripton and keywords to tag the pic)
e) If data are correct, the two pics are copied in their respective directory and there are unlink in the tmp file using unlink().

If you unplug the ability to refresh the script that copies/creates the images then when they refresh the second form it won't do anything. Having the processing as part of the script is where you get refresh problems. This may make some extra programming but will save a lot of hassle in the long run.

I always think that it is a bad plan to have processing and display in the same script all the time. It makes browser refresh a problem. I try to unplug the actuall processing and put it into a seperate script that contains no output. Then the back button and refresh do not cause things to be re-processed.

About processing and displaying in the same page, I will try to follow your advice in the future. Because I do not want to modify my script now, I have decided that I will sometimes delete old files (mostly those submitting twice) from the first upload directory.

Tomda