Results 1 to 6 of 6

Thread: public variable

  1. #1
    Join Date
    Apr 2003
    Posts
    137

    Unanswered: public variable

    how can i save and read a public variable to be used for my whole php website?

    I am currently using this but it's useless..

    session_start();
    $_SESSION["login_name"]= "txtLogin";
    $_SESSION["login_password"]= "txtPassword";

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    The best and quickest operating way to have unique variables for each visitor that are available on all the pages on your web site is to use the $_SESSION variables.

    So, it is best to troubleshoot why these are not working in your code. What about them don't work, what symptoms do you have, what error messages do you get?

  3. #3
    Join Date
    Apr 2003
    Posts
    137
    i am not getting any error but when i read the session value it's blank.. can you please post a step-by-step example on how to write and how to read a session variable?

  4. #4
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    See the two examples at this link - http://www.php.net/manual/en/function.session-start.php

  5. #5
    Join Date
    Apr 2003
    Posts
    137
    i wanted to ask you..

    is this the right way to use $_SESSION in the SQL statement?

    $str_sql = "SELECT customer_id, first_name, last_name, e_mail, login_name, login_password, company, local_phone FROM customers where login_name = '$_SESSION[login_name]' and login_password = '$_SESSION[login_password]'";

  6. #6
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    Your session variable keys should be in quotes. Like this:
    $_SESSION["login_name"]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •