記錄使用者登入日誌

2021-09-08 21:15:19 字數 3227 閱讀 3001

我們可以在專案中,實現使用者登入日誌記錄。簡單實現方法,如下:

在資料中建立一張表,儲存一些相關的資訊。

setansi_nulls 

ongo

setquoted_identifier 

ongo

create

table

[dbo].

[loginlog](

[loginlogid][

int]

identity(1

,1) not

null,[

usersid][

int]

notnull,[

ip][nvarchar](

20) 

notnull,[

computername][

nvarchar](

50) 

null,[

logintime][

datetime

]not

null,[

activex][

bit]

notnull,[

cookies][

bit]

notnull,[

css]

[bit

]not

null,[

languages][

nvarchar](

30) 

null,[

platform][

nvarchar](

30) 

null,[

useragent][

nvarchar](

300) 

null

,primary

keyclustered([

loginlogid

]asc

)with

(pad_index  

=off

, statistics_norecompute  

=off

, ignore_dup_key 

=off

, allow_row_locks  =on

, allow_page_locks  =on

) on

[primary]) 

on[primary]go

alter

table

[dbo].

[loginlog

]add

default

(getdate

()) 

for[

logintime]go

alter

table

[dbo].

[loginlog

]add

default((0

)) for

[activex]go

alter

table

[dbo].

[loginlog

]add

default((0

)) for

[cookies]go

alter

table

[dbo].

[loginlog

]add

default((0

)) for

[css]go

然後,再建立乙個儲存過程,對錶進行插入動作。

setansi_nulls 

ongo

setquoted_identifier 

ongo

alter

procedure

[dbo].

[usp_loginlog_insert](

@usersid

int,

@ipnvarchar(20

),@computername

nvarchar(50

),@activex

bit,

@cookies

bit,

@css

bit,

@languages

nvarchar(30

),@platform

nvarchar(30

),@useragent

nvarchar

(300))

asbegin

transaction

insert

into

[dbo].

[loginlog](

[usersid],

[ip],

[computername],

[logintime],

[activex],

[cookies],

[css],

[languages],

[platform],

[useragent]) 

values

(@usersid

,@ip

,@computername

,getdate

(),@activex

,@cookies

,@css

,@languages

,@platform

,@useragent)if

@@error

<>

0begin

rollback

transaction

endcommit

transaction

private

void

recordloginlog(

string

usersid)

上面loginlog類別中,它有乙個insert()方法 

public

void

insert(

string

usersid, 

string

ip, 

string

computername, 

bool

activex, 

bool

cookies, 

bool

css, 

string

languages, 

string

platform, 

string

useragent)

;objbusinessbase.executeprocedure(

"usp_loginlog_insert

", parameter);}

Linux檢視登入使用者日誌

一 linux記錄使用者登入資訊檔案 1 var run utmp 記錄當前正在登入系統的使用者資訊 2 var log wtmp 記錄當前正在登入和歷史登入系統的使用者資訊 3 var log btmp 記錄失敗的登入嘗試資訊。二 命令用法 1.命令 last,lastb show a listi...

JS記錄使用者登入次數

function www helpor net offset function getcookie name return null function setcookie name,value var expdate new date var visits expdate.settime expda...

hbase記錄使用者訪問日誌

我們目前對每天的使用者訪問量,使用者活躍度的統計僅僅是用growingio,統計得不是很準確。因此需要自己在後台做使用者訪問記錄,以便分析使用者行為,選擇hbase資料庫做使用者行為記錄。hbase資料庫裡面,每個系統每天的訪問日誌記錄在一張表上,由於hbase只能按照rowkey來快速檢索資料,並...