Sessions and variables.. another way?

Discussion in 'PHP' started by debz89uk, Mar 23, 2010.

  1. #1
    I have a page that display two different things depends on whether the information was entered by uploading a file or entering a form.

    So i have a variable I have named "option" that changed depends on which of these was performed. I have this working using a session as I cannot use "$_POST" because it goes from the index page to a php page and back to the index page again. However, because I am using a sessions (which is also used for my login), the variables are destroyed when i close the browser (and I need them to stay as they are forever), however, I cannot change the length/life of the session because I want users to be logged out automatically when the close the browser.

    Is there another way that I can transfer these varible along the pages?
     
    debz89uk, Mar 23, 2010 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tried using Cookies?
     
    Wrighty, Mar 23, 2010 IP
  3. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #3
    You try to keep those variables at tables
     
    ziya, Mar 23, 2010 IP
  4. debz89uk

    debz89uk Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Actually, I've done something that has it working.. when the session starts the variable is one of 2 things, and each of these has a loop, so I've just made a variable equal to the sessions (kind of reverse of what I do for it to go through the php page) and this works throughout the whole thing. Thanks for your help anyway :)
     
    debz89uk, Mar 23, 2010 IP
  5. debz89uk

    debz89uk Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Nope turns out that isnt working, seemed to work for one but not the other....

    Is there a simple way to pass these variables without them being reset?
     
    debz89uk, Mar 24, 2010 IP
  6. GNetCoder

    GNetCoder Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You mentioned in the OP that you needed $option to stay set forever; If you are using sessions for authentication does it also use mysql to store user info? If so you could create another column in an existing table or a separate table in your DB to store that info. Then when the same user logs in again $option will be available, same as last time.
     
    GNetCoder, Mar 24, 2010 IP
  7. debz89uk

    debz89uk Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That's interesting, I never thought of that. Thanks =)
     
    debz89uk, Mar 24, 2010 IP