title: Auto submit login form and start session
body: <p>I am trying to auto submit login form by using javascript but it cannot start session and redirect to same page but when i am try to submit same form without javascript it working.
  I need to submit form automatically. Any suggestion?</p>
  
  <pre><code>&lt;?php include('_header.php'); ?&gt;
      &lt;form id="my_form" method="post" action="index.php" name="loginform"&gt;
          &lt;label for="user_name"&gt;&lt;?php echo WORDING_USERNAME; ?&gt;&lt;/label&gt;
          &lt;input id="user_name" type="text" value="something" name="user_name" required /&gt;
          &lt;label for="user_password"&gt;&lt;?php echo WORDING_PASSWORD; ?&gt;&lt;/label&gt;
          &lt;input id="user_password" type="hidden" value="something1" name="user_password" /&gt;
          &lt;input type="checkbox" id="user_rememberme" name="user_rememberme" value="1" /&gt;
          &lt;label for="user_rememberme"&gt;&lt;?php echo WORDING_REMEMBER_ME; ?&gt;&lt;/label&gt;
          &lt;input type="submit" name="login" value="&lt;?php echo WORDING_LOGIN; ?&gt;" /&gt;
      &lt;/form&gt;
      &lt;script type="text/javascript"&gt;
          function submitForm() {
              document.getElementById('my_form').submit();
          }
          window.onload = submitForm;
      &lt;/script&gt;
      &lt;a href="register.php"&gt;&lt;?php echo WORDING_REGISTER_NEW_ACCOUNT; ?&gt;&lt;/a&gt;
      &lt;a href="password_reset.php"&gt;&lt;?php echo WORDING_FORGOT_MY_PASSWORD; ?&gt;&lt;/a&gt;
  &lt;?php include('_footer.php'); ?&gt;
  </code></pre>