save all variables in a cookie when the user leaves the page

Discussion in 'Javascript' started by windandwaves, Feb 26, 2007.

  1. windandwaves

    windandwaves Guest

    Hi Folk

    On one of my sites, I have a reather involved page (searchable map).
    When the person leaves the page then all the AJAX generated
    information is lost. Is there a way that I can retain all this data
    in a cookie or so or how would you recommend I saved all the users
    information (perhaps using a database on the serverside).

    Any recommendations greatly appreciated.

    Ta

    Nicolaas
     
    windandwaves, Feb 26, 2007
    #1
    1. Advertising

  2. windandwaves

    Une Bévue Guest

    windandwaves <> wrote:

    > Any recommendations greatly appreciated.


    i think the best would be using json.js (see json.org) :

    u serialize your datas and put them in a cookie as a string.

    beware the size of a cookie is limited (don't remember how).

    here i do have a first test of such kind of storing datas in a cookie :

    <http://www.yvon-thoraval.com/Cookies/cookie_object_json.xhtml>

    with four data values :

    - pure string ;
    - an array with an object as a value ;
    - a pure object ;
    - an object with an array as a value.

    This is work on progress because i've discovered json 2 days ago )))

    As far as i understand well, json will be included in a future version
    of JavaScript ;-)
    --
    Une Bévue
     
    Une Bévue, Feb 26, 2007
    #2
    1. Advertising

  3. windandwaves

    ASM Guest

    windandwaves a écrit :
    > Hi Folk
    >
    > On one of my sites, I have a reather involved page (searchable map).
    > When the person leaves the page then all the AJAX generated
    > information is lost.


    Isn't it user's problem ?
    Next time he'l visit this page he'l have to run back all he has done
    (probably his browser will remember what was in text-fields ?)

    > Is there a way that I can retain all this data
    > in a cookie or so or how would you recommend I saved all the users
    > information (perhaps using a database on the serverside).


    <body onunload="document.myForm.submit()">
    or
    <body onbeforeunload="document.myForm.submit()">

    those will fire as soon as :
    - you quit the browser
    or
    - you close the window
    or
    - you call a new file in same window <-- important




    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Feb 26, 2007
    #3
  4. windandwaves

    Randy Webb Guest

    ASM said the following on 2/26/2007 4:50 AM:

    <snip>

    > <body onunload="document.myForm.submit()">
    > or
    > <body onbeforeunload="document.myForm.submit()">
    >
    > those will fire as soon as :


    You hope they fire.

    > - you quit the browser


    Not if the power fails to quit the browser.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Feb 26, 2007
    #4
  5. windandwaves

    ASM Guest

    Randy Webb a écrit :
    > ASM said the following on 2/26/2007 4:50 AM:
    >
    >> <body onunload="document.myForm.submit()">
    >> or
    >> <body onbeforeunload="document.myForm.submit()">
    >>
    >> those will fire as soon as :

    >
    > You hope they fire.


    Exacktelelly, we hope that does, and we hope the server continues to
    run, and we hope the battery of conputer is ok, and we hope Windows
    haven't lost its babies, and we hope the house is not destroying, and we
    hope ...

    >> - you quit the browser

    >
    > Not if the power fails to quit the browser.


    Nor if is the end of world.



    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Feb 26, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jorge_Beteta
    Replies:
    4
    Views:
    8,792
    Shiv Kumar
    Jan 12, 2004
  2. subhadip
    Replies:
    0
    Views:
    661
    subhadip
    Mar 28, 2007
  3. Tory

    Capturing event when user leaves a cell?

    Tory, Apr 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    121
  4. Mike Dee
    Replies:
    0
    Views:
    391
    Mike Dee
    Mar 2, 2006
  5. Alex
    Replies:
    1
    Views:
    95
    Martin Honnen
    Dec 28, 2006
Loading...

Share This Page