How to make Global Variables with PHP?

Discussion in 'PHP' started by Davidf25sc, Sep 15, 2006.

  1. #1
    Hey, im kinda new to php, i have some experience programming with it, but i was wondering if there are such things as Global Variables with php, like the $session variables with ASP? a variable i can pass to another page to make something with it, but without the need to put it in the address bar like this : hxxp://www.something.com/login.php?var1=value&var2=value.
    I want this two variables for example to be "global" so that i can use them in anothere php page.
    Thanks.
     
    Davidf25sc, Sep 15, 2006 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
  3. Davidf25sc

    Davidf25sc Active Member

    Messages:
    165
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Well, your answer is pretty clear i think...thanks.
     
    Davidf25sc, Sep 15, 2006 IP
  4. sanjeevan_a

    sanjeevan_a Peon

    Messages:
    42
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you need to call session_start() on each page you want to access session variables. To put variables into the session try:

    $_SESSION['foo'] = 'bar';
    PHP:
     
    sanjeevan_a, Sep 15, 2006 IP
  5. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you need one session variables or global application varialbes. I think the last variant could be solved using shared memory
     
    intoex, Sep 17, 2006 IP