Are arrays unique the the user's browser?

Discussion in 'PHP' started by LOOM, Feb 3, 2014.

Thread Status:
Not open for further replies.
  1. #1
    Hi everyone,

    I have a quick question about arrays.

    1. User 1 is in a product page and the array is made
    2. User 2 is also in a product page and a new array is made for this user

    The question:
    Will the first users array be unique to his browser or will his array be overridden once user 2 enters the product page.

    I know that SESSION are designed to keep an array unique to the users browser but i would like to know how the normal array works.

    and if the array is overridden what is the point in having arrays over SESSION's or am i just missing something here?

    Thanks for reading.
     
    Solved! View solution.
    LOOM, Feb 3, 2014 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Normal arrays only live for as long as the script is running - and that is unique to the page request (not the browser).

    So if I have requested a page I'll get my version and you will get another.
     
    sarahk, Feb 3, 2014 IP
  3. LOOM

    LOOM Greenhorn

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Hi sarahk,

    one more thing, what if both users enter the page at the same time will there be any conflict?

    Thanks for the reply.
     
    LOOM, Feb 3, 2014 IP
  4. #4
    Nope, none whatsoever.

    Unless they're both updating a row in a table in your database, or winning a prize for being the millionth visitor but that comes down to the rules of your application - the arrays will still be independant.
     
    sarahk, Feb 3, 2014 IP
Thread Status:
Not open for further replies.