//同步代码 <?php $auth_key = '******'; $co_logintime = getcvar('truelogintime',1); $auth_code = md5($logininid.$loginin.$auth_key.$co_logintime); echo '<script type="text/javascript" src="/syncauth.js?auth='.$auth_code.'"></script>'; ?>
$phome_cookievarpre='l4'; //前台cookie变量前缀 $phome_cookieadminvarpre='l4'; //后台cookie变量前缀
//修改--------------------- 'mysql' => array( 'driver' => 'mysql', 'host' => '127.0.0.1', 'database' => '******', 'username' => '******', 'password' => '******', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'pre_', ), //添加--------------------- 'synclogin' => array( 'driver' => 'mysql', 'host' => '127.0.0.1', 'database' => '*******', 'username' => '******', 'password' => '******', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'phome_', ),
4、修改la4用户登录模型/application/app/models/User.php
修改并添加如下代码
//修改&添加---------------- protected $connection = 'synclogin';//此与上一步数据库对应相对应 protected $table = 'enewsuser'; //这个为验证用户的用户表 protected $primaryKey = 'userid'; //用户自增id
5、修改La4路由/application/app/routes.php
在路由配置文件里面添加如下代码 (注意与第一部的auth_key值相同)
Route::get('syncauth.js',function(){ if(!Auth::check()){ $auth_key = '******'; $auth_code = Input::get('auth',''); $userid=isset($_COOKIE['l4loginuserid'])?$_COOKIE['l4loginuserid']:0; $username=isset($_COOKIE['l4loginusername'])?$_COOKIE['l4loginusername']:0; $jplogintime=isset($_COOKIE['l4logintime'])?(int)$_COOKIE['l4logintime']:0; $jptruelogintime=isset($_COOKIE['l4truelogintime'])?(int)$_COOKIE['l4truelogintime']:0; $encry_code = md5($userid.$username.$auth_key.$jptruelogintime); if($encry_code == $auth_code){ $user = User::find($userid); Auth::login($user); } } }); Route::filter('admin_auth', function(){ if(!Auth::check()){ return Redirect::to('/e/admin'); } });
6、登录帝国后台/e/admin/可以同步登录laraval4