#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2005
    Posts
    125
    Rep Power
    10

    AJAX store large form progress in SESSION


    Hey guys,

    I've recently started working on a large form which I update with ajax + php to a database at regular intervals. I read an article the other day which mentioned that they save the form details to a SESSION variable instead and then do one database call to save in the end.

    I was thinking is this a bad idea. Having many users store lots of data to a session variable? I just thought I would ask before I change it over.

    Thanks
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If the data is small enough that you can regularly sync it to the server using AJAX then I don't think you'll have any size issues with storing it in a session.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    Well that would depend on how many users you are planning on to be active at once, the system resources available to be allocated to php, and of course what you are storing.

    However session data is usually going to be saved either in a text file or database table depending on your php configuration and should clean up inactive sessions so unless you have thousands of users with session data exceeding a couple of KB then it shouldnt be an issue. But what is it that you are wanting to store for the life of the session?

    Originally Posted by doush.
    Hey guys,

    I've recently started working on a large form which I update with ajax + php to a database at regular intervals. I read an article the other day which mentioned that they save the form details to a SESSION variable instead and then do one database call to save in the end.

    I was thinking is this a bad idea. Having many users store lots of data to a session variable? I just thought I would ask before I change it over.

    Thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2005
    Posts
    125
    Rep Power
    10
    Yeah that makes sense. I probably should see how big one text file becomes and see if it will be acceptable. If anything I can give much more memory to php.

    Originally Posted by portcitysoftwar
    Well that would depend on how many users you are planning on to be active at once, the system resources available to be allocated to php, and of course what you are storing.

    However session data is usually going to be saved either in a text file or database table depending on your php configuration and should clean up inactive sessions so unless you have thousands of users with session data exceeding a couple of KB then it shouldnt be an issue. But what is it that you are wanting to store for the life of the session?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    What is the durration of the php sessions. Browsing session, or fixed time?

    Originally Posted by doush.
    Yeah that makes sense. I probably should see how big one text file becomes and see if it will be acceptable. If anything I can give much more memory to php.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2005
    Posts
    125
    Rep Power
    10
    Its browsing but I kill it once the form submits. Would you recommend setting it to fixed time so it doesn't waste too much room?

    Originally Posted by portcitysoftwar
    What is the durration of the php sessions. Browsing session, or fixed time?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    Well as long as your properly ending the session after the form is submitted it should be doing exatly what you want. Hold data until the user either ends his browsing session or submits his form

    Originally Posted by doush.
    Its browsing but I kill it once the form submits. Would you recommend setting it to fixed time so it doesn't waste too much room?
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    105
    Rep Power
    51
    Originally Posted by portcitysoftwar
    What is the durration of the php sessions. Browsing session, or fixed time?
    This depends on your host. They may have set a session lifetime.

    session_set_cookie_params
    Post to Facebook using a Nokia 3310

IMN logo majestic logo threadwatch logo seochat tools logo