Note that there are some explanatory texts on larger screens.

plurals
  1. POnonce token after ajax response and hash problems using ajax jquery type json
    primarykey
    data
    text
    <p>i have login with my own code at php, now i dont so good at jquery ajax and so on, my login using ajax jquery type json , i take all vals and post them to server side php which check all details , and response answer via the same jquery ajax .</p> <p>the problem is i added nonce token that maded in php to the login form and every time after user try to login the nonce change , the problem is only when i refresh the login page the nonce changed to the good nonce else its will keep the same nonce token and will send with the post not the updated one because the ajax didnt refresh the page after login .</p> <p>So the question is how i trigger the ajax to refresh the nonce token after every response ? the nonce token is write in php.</p> <p>and more thing about the hash nonce token , its make that hash string sometime:</p> <p>asdaskjn34kj+sdf/sd=</p> <p>now the ajax jquery auto remove the '+' from the hash string so its send wrong token in the POST, here my hash function :</p> <pre><code>public static function RandomBytes($count, $printable=FALSE) { $bytes = ''; // supress warnings when open_basedir restricts access to /dev/urand if(@is_readable('/dev/urandom') &amp;&amp; ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) { $bytes = fread($hRand, $count); fclose($hRand); } if((strlen($bytes) &lt; $count) &amp;&amp; function_exists('mcrypt_create_iv')) { // Use MCRYPT_RAND on Windows hosts with PHP &lt; 5.3.7, otherwise use MCRYPT_DEV_URANDOM // (http://bugs.php.net/55169). if ((version_compare(PHP_VERSION, '5.3.7', '&lt;') &amp;&amp; strncasecmp(PHP_OS, 'WIN', 3) == 0)) $bytes = mcrypt_create_iv($count, MCRYPT_RAND); else $bytes = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM); } if((strlen($bytes) &lt; $count) &amp;&amp; function_exists('openssl_random_pseudo_bytes')) // OpenSSL slow on Win { $bytes = openssl_random_pseudo_bytes($count); } if ((strlen($bytes) &lt; $count) &amp;&amp; @class_exists('COM')) { // Officially deprecated in Windows 7 // http://msdn.microsoft.com/en-us/library/aa388182%28v=vs.85%29.aspx try { $CAPI_Util = new COM('CAPICOM.Utilities.1'); if(is_callable(array($CAPI_Util,'GetRandom'))) { $bytes = $CAPI_Util-&gt;GetRandom(16,0); $bytes = base64_decode($bytes); } } catch (Exception $ex) { } } if (strlen($bytes) &lt; $count) { // This fallback here based on phpass code $bytes = ''; $random_state = microtime(); if (function_exists('getmypid')) $random_state .= getmypid(); for ($i = 0; $i &lt; $count; $i += 16) { $random_state = md5(microtime() . $random_state); $bytes .= pack('H*', md5($random_state)); } $bytes = substr($bytes, 0, $count); } if ($printable) return base64_encode($bytes); else return $bytes; } </code></pre> <p>any one know how to change this function to make the strings without '+' in the hashesh?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload