Translate PHP to Node.js
-
I can't get to translate this piece of code to place it in my NodeBB. I'd be thankful if yoy guys can help out!
<? session_set_cookie_params(0, '/', '.site.net'); session_start(); if(!isset($_SESSION["auth_token"])) { $_SESSION["auth_token"] = bin2hex(random_bytes(16)); $full_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; header("Location: https://secure.site.net/auth/$_SESSION[auth_token]?return_url=".$full_url); } ?>
-
NodeBB doesn't use
$_SESSION
or auth tokens in this manner. I think you should look into the session sharing plugin instead:GitHub - julianlam/nodebb-plugin-session-sharing: Allows login sessions from your app to persist in NodeBB
Allows login sessions from your app to persist in NodeBB - julianlam/nodebb-plugin-session-sharing
GitHub (github.com)
-
@julian thanks, but I do not understand what is that. My webmaster helped me with the PHP code, but I'm not a programmer, and he does not use Node.js.
can you please paste the code conversion so that I can place it in my index.js
Copyright © 2024 NodeBB | Contributors