form實現自動認可代碼分享

來源:互聯網
上載者:User
在做項目中,例如b2b的由商城跳往賣家中心的後台,當他既有會員帳號又是賣家的時候,讓他登入了商城,就不需要賣家登入的時候,處理過程中可以用到form表單自動登入。本文主要為大家帶來一篇form自動認可執行個體講解。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,希望能協助到大家。

實現簡單思路:可以再普通會員登入的地方,登入成功可以將登入名稱和密碼,使用者id存起來,為了安全可以aes加密(前面一篇文章有詳細介紹),存入cookie,在頁面中需要去賣家中心,那邊可以判斷開始所存的cookie,以及判斷是否是賣家,如果是,用form表單自動給他登入。

在ecshop上面實現的案例:

在includes下面建立一個lib_stm_form.php:


class form{  public function hform($username,$password){    $str = '<body><form action="privilege.php" method="post" id="qqform" name="qqform" style="display:none"> ' ;    $str .= '帳號:<input type="text" name="username" value="' . $username . '" /><br />' ;    $str .= '密碼:<input type="text" name="password" value="' . $password . '" /><br />' ;    $str .='<input type="hidden" name="act" value="signin" /></form></body>';    $str .= '<script>window.onload= function(){document.getElementById("qqform").submit();}</script>';    echo $str; exit;  }}?>

在privilege.php的signin方法中,進行aes解密,引入lib_stm_form.php::


require_once(ROOT_PATH . 'includes/lib_smt_from.php');$form   = new form();$username = $j_token['username'];$password   =$j_token['password'];$a = $form->hform($username,$password);exit;

這樣就實現了,form的自動認可登入,如果是會員和賣家身份的,就可以實現了登入一次就好。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.