jorgep Posted April 11, 2008 Share Posted April 11, 2008 Hello Fellows, This is kind of complicated problem to explain, I'll do my best to make it clear: The Process: I have a huge process where I fetch contacts information from a database and from a csv file and then use this contacts data to create a PDF file (I'm using PDFlib). When all the process is done, I set some session variables that include information from the generated file and forces a download through php headers. The Problem: After I process more than 6000 contacts (around 10 minutes processing) when I force the download it seems that the sessions variables don't get correctly set. I'm almost sure is not a session variable problem (like headers already sent) since it works fine for less than 6000 contacts. My Suspects: 1.- PDFlib dies some how and echo something and I can not set my session variables correctly 2.- Something regarding the memory usage My configuration: max_execution_time = 3600 max_input_time = 3600 memory_limit = 2048M I need to process around 12000+ contacts if you have a clue of what could be happening that would be great! Thanks for reading and any hint/help/guide would be highly appreciated Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/ Share on other sites More sharing options...
cooldude832 Posted April 11, 2008 Share Posted April 11, 2008 sessions can be set pre/post any output however the end client can't update the sessions after output. so [code] <?php session_start(); echo "bob"; $_SESSION['val'] = "bob"; #The session for the user is now blank ?> <?php session_start(); $_SESSION['val'] = "Bob"; #session is Bob echo "bob"; $_SESSION['val'] = "Joe"; #still bob ?> [/code] Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-514939 Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 sessions can be set pre/post any output however the end client can't update the sessions after output. so [code] <?php session_start(); echo "bob"; $_SESSION['val'] = "bob"; #The session for the user is now blank ?> <?php session_start(); $_SESSION['val'] = "Bob"; #session is Bob echo "bob"; $_SESSION['val'] = "Joe"; #still bob ?> [/code] Excuse me? Where did you hear that rubbish? jorgep: You might want to check your session.cookie_lifetime. It's possible the sessions are timing out. Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-514949 Share on other sites More sharing options...
jorgep Posted April 11, 2008 Author Share Posted April 11, 2008 Thanks for the reply cooldude832 and GingerRobot. cooldude832: I know that, and that is almost dismissed since the script is working perfectly for less than 6000 contacts GingerRobot: That sounds very logic, I just checked it and it is set to 0 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime = 0 Do you think I should set it to a number or something? It's a pain in the rear to test this script since I have to wait 40+ minutes until I get a result back. Thanks again for your answer Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-514972 Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 0 should be fine. It might be worth setting PHP to ignore a user abort. I seem to remember some issues with scripts taking a long time to execute relating to this setting, though i can't find anything to confirm that at the moment. If you want to give it a try, add this: ignore_user_abort(TRUE); To the top of your script. I think the idea goes something like that if the browser doesn't recieve any information for a while, it terminates the session. I could be talking rubbish here though - as i say, its just a vague recolection. Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-514991 Share on other sites More sharing options...
jorgep Posted April 11, 2008 Author Share Posted April 11, 2008 Thanks GingerRobot, I will add that in my next test right now I have to wait like 987982743 years for the script to finish! I'll post the results later! Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-514995 Share on other sites More sharing options...
jorgep Posted April 11, 2008 Author Share Posted April 11, 2008 ;D ;D It worked!! I don't know why it just took 20 minutes to process all 12000+ contacts, man! I've become an optimization guru after this hahaha! At the beginning of the main function i added ini_set("session.cookie_lifetime",4000); Thanks a lot GingerRobot you rock! Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-515011 Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 Great stuff - though if this isn't a one-off, you wont know if you've solved the problem until you run this and it takes a similar amount of time again. Hopefully it's sorted, however. Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-515020 Share on other sites More sharing options...
jorgep Posted April 11, 2008 Author Share Posted April 11, 2008 Yup, it worked, I did it again and this time it last 39 minutes and worked fine. What I'm not sure if it was that specific change that made it work, cuz I added some other stuff. Thanks anyway I could say that your suggestion solved it hehe! Link to comment https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/#findComment-515135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.