php: pass large arrays of data through pages

By : Dennis
Source: Stackoverflow.com
Question!

I am trying to to solve a problem where I need to pass large arrays of data to another page, this is my scenario:

The user input his/her gmail login information inside a form, I then send this information to an ajax page where i authenticate and fetch all the contacts, if the login is invalid they can try again but if it authenticated I need to send them to the next page where I parse all the emails and check if they match any users on the site.

Method 1 (didn't work):

Store all the data inside a session, this only work if the array is small as there is a size limit for the sessions.

Method 2 (didn't work):

Add an hidden input with javascript and then submit the form (also with javascript). As it turns out you can't submit the form and return true (change page) unless the user triggers the event.

So how should I go on, should I just skip the ajax authentication and send them back to the previous page if it didn't work or is there some workaround to my problem?

By : Dennis


Answers

If you are able to fetch the data again on the next page, you could do that instead of passing it between pages.

By : GSto


Since you are using jQuery you can submit the data directly or as a hidden element on the form without a user click. Assuming the second submission is via AJAX you can:

 $("#mydiv").load("secondpage.php", {email1: 'blah'}, function(){
   alert("Submitted everything nicely");
 });


Depending on your webserver, but session variables do not typically have a size restriction. Apache PHP you could handle extremely large sizes, instead you should care about http://ca.php.net/manual/en/ini.core.php#ini.memory-limit. In addition, PHP.ini carries session.size variable that you could adjust. I am not sure how it did not work for you; you used $_SESSION, right?

Finally, to make a better persisting yet fast (faster than Database) volatile storage I would recommend using By : Terry Felkrow



This video can help you solving your question :)
By: admin