Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Recognizing authenticated users outside the forum
rstober
New
I have a custom PHP-driven site (not wordpress or any other CMS). I have embedded the Vanilla 2 forum. You can see the site here: http://www.openlava.net/index.php?tb=forum.
I'd like to be able to recognize logged in users from pages that are outside the forum. I've tried printing the global $_SESSION and $_COOKIE arrays from my main page but I don't see any session variables or cookies that are associated with the forum...
How can get information about Vanilla 2 logged in users from outside the forum? Can anyone point me to an example?
Thank you, Robert
I'd like to be able to recognize logged in users from pages that are outside the forum. I've tried printing the global $_SESSION and $_COOKIE arrays from my main page but I don't see any session variables or cookies that are associated with the forum...
How can get information about Vanilla 2 logged in users from outside the forum? Can anyone point me to an example?
Thank you, Robert
Tagged:
0
Best Answer
-
Aolee ✭✭i think had the same problem before
hope this will help.
add this somewhere in your codedefine('APPLICATION', 'Vanilla'); define('APPLICATION_VERSION', '2.0.16'); define('DS', '/'); define('PATH_ROOT', 'path-to-forum'); ob_start(); require_once(PATH_ROOT.DS.'bootstrap.php'); ob_end_clean(); // clear any header output from vanila $Session = Gdn::Session(); $Authenticator = Gdn::Authenticator(); if ($Session->IsValid()) { $Name = $Session->User->Name; echo "You are logged in as $Name"; } else { echo "You are not logged in"; }
it was taken here http://www.vanilla-wiki.info/Code/Authorization
this helped me integrate openclassifieds to vanilla 2.
if you're looking for the $_SESSION thing do this
print_r($Session)
and you'll get what you need.
0
Answers
// print out session vars
var_dump($_SESSION);
// print out cookies vars
var_dump($_COOKIE);
If vanilla is setting cookies or session variables I should be able to use them too. Can anyone provide a hint?
If you have some questions, feel free to ask, if i can, i will help you.
How can I print out the Vanilla 2 session variables from out side the forum?
hope this will help.
add this somewhere in your code
define('APPLICATION', 'Vanilla'); define('APPLICATION_VERSION', '2.0.16'); define('DS', '/'); define('PATH_ROOT', 'path-to-forum'); ob_start(); require_once(PATH_ROOT.DS.'bootstrap.php'); ob_end_clean(); // clear any header output from vanila $Session = Gdn::Session(); $Authenticator = Gdn::Authenticator(); if ($Session->IsValid()) { $Name = $Session->User->Name; echo "You are logged in as $Name"; } else { echo "You are not logged in"; }
it was taken here http://www.vanilla-wiki.info/Code/Authorization
this helped me integrate openclassifieds to vanilla 2.
if you're looking for the $_SESSION thing do this
print_r($Session)
and you'll get what you need.
The sites aren't on the same domain, but they have access to the same database. If there is another way this can be achieved, please let me know.
@AoleeI I get the following error when trying this Class 'Gdn' not found?