Pass the logged in username the sAjaxSource

Pass the logged in username the sAjaxSource

SomethingSevenSomethingSeven Posts: 2Questions: 0Answers: 0
edited December 2012 in General
Guys,

I'm having trouble passing the logged in username (WordPress) to the sAjaxSource php file so I can mysql_query appropriately. I've tried to globalize my username variable, use an include.php file with the username in it to no avail..

How do I pass a php variable into the sAjaxSource file from my php file that displays the data??

Thanks!

Replies

  • SomethingSevenSomethingSeven Posts: 2Questions: 0Answers: 0
    I got it working with PHP session variables.. but if this is bad practice, somebody shout out!

    In my php file that houses the DataTable:
    [code]
    session_start(); // must be called before data is sent
    $_SESSION['user_name'] = $current_user->user_login;
    [/code]

    And in my sAjaxSource php file:
    [code]

    session_start(); // must be called before data is sent
    $_SESSION['user_name'] = $current_user->user_login;
    [/code]
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    That'd say you are much safer that way than passing it in as part of the Ajax request. Still open to session hijacking, but that's way outside the scope of this forum :-). A google search for PHP session hijacking might prove useful to help harden your script as much as possible.

    Allan
This discussion has been closed.