i create custom login page outside magento. need form_key.
how can current form_key using javascript and/or php outside magento?
notes:
i willing add php file inside magento generate for_key (but don't know write , place it).
i new magento.
i running magento 2.0.
i came whit solution. please find me better one!
<!doctype html> <html> <head> <meta charset="utf-8"> <title>get form key</title> <script> window.onload=function(){ /* form_key magento */ var ajax = new xmlhttprequest(); ajax.open("post", "/", false); ajax.send(); document.getelementbyid('hidden_div').innerhtml = ajax.responsetext; var the_form_key = document.getelementsbyname("form_key")[0].value; alert(the_form_key); }; </script> </head> <body> <div id="hidden_div" style="display:none"></div> </body> </html>
Comments
Post a Comment