2

I am working with PHP and JavaScript. I integrated metamask with PHP, so for this I am using "Ajax", but I want to know that how we can use "jwt token" (create) if we successfully connected with Metamask?

Here is my current code

<script>
    const ethereumButton = document.querySelector('.enableEthereumButton');
    const showAccount = document.querySelector('.showAccount');
                
    ethereumButton.addEventListener('click', () => {
        getAccount();
    });
                
   async function getAccount() {
   const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
   const account = accounts[0];
            $('#cst_account_var').val(account);
            var bla = $('#cst_account_var').val();
            
            $.ajax({
             type: "POST",
             url: "<?php echo base_url(); ?>/admin/add_wallet", 
             data: {wallet: bla},
             dataType: "text",  
             cache:false,
             success: 
                  function(data){
                    window.location.replace("<?php echo base_url(); ?>profile");
                  }
              });
         }

</script> 
TylerH
  • 20,799
  • 66
  • 75
  • 101
Jolly
  • 55
  • 3
  • You can use local storage for this . This is related question https://stackoverflow.com/questions/55631012/how-to-store-jwt-token-in-localstorage-and-send-it-back-to-the-server-with-heade – firatt_ Feb 09 '23 at 08:04

0 Answers0