few php session related questions

Discussion in 'PHP' started by phpwreker, Dec 9, 2012.

  1. #1
    <? php session_start()

    $_SESSION [ "variable value" ];



    from where does that variable value come from ?

    from the

    form ?
    database?

    and how can GET that variable name and send it via email ? is it possible in a scenario like this ?


    [​IMG]
     
    Last edited: Dec 9, 2012
    phpwreker, Dec 9, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    In your code it doesn't, it throws an error.

    In code that runs, it gets its value from the assignment statement that assigns it:

    $_SESSION['my_variable'] = 12345;

    It doesn't. The mail() function sends whatever you put into its variables.

    (You're going to keep getting answers that make no sense to you, because you keep asking questions that make no sense.)
     
    Rukbat, Dec 9, 2012 IP
  3. davetrebas

    davetrebas Active Member

    Messages:
    301
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Session variables allow you to persist values for one user with multiple pages. The mechanism used is either cookies or in the url string.

    You have to set them before using them since session variables are just an array.

    As to email. That is another problem. Once set, the session variables can be used like other variables to create email, etc.

    You can also use isset to verify that the session variable has been set.
     
    davetrebas, Dec 9, 2012 IP
  4. bigmarvelfan

    bigmarvelfan Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can have users setting the sessions through form fields.

    $_SESSION['name'] = $_POST['name'];
    $_SESSION[address] = $_POST[address];
    $_SESSION[city] = $_POST[city];
    $_SESSION[state] = $_POST[state];
    $_SESSION[zip] = $_POST[zip];
     
    bigmarvelfan, Dec 11, 2012 IP
  5. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #5
    I would suggest being extremely careful setting raw POST variables to a session variable or using them in any way as-is. At the very least you need to sanitize the user input before using it for anything.
     
    jestep, Dec 11, 2012 IP
  6. paulinetaylor85

    paulinetaylor85 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    The session value of the variable is assigned from whatever the value of variable is set.
     
    paulinetaylor85, Dec 12, 2012 IP
  7. paulinetaylor85

    paulinetaylor85 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    [TABLE]
    [TR]
    [TD="width: 390"]Just create header files for every page where it is necessary. Provide your metatags in your header file and call the header file where you need your metatags to be placed.
    [/TD]
    [/TR]
    [/TABLE]
     
    paulinetaylor85, Dec 13, 2012 IP