摘要
传统的使用session记录验证码的方法存在缺陷:如果客户端无法使用cookie,则无法正确的进行验证。故文章提出了一种通过Mysql数据库来记录验证码的方法。首先web服务器收到客户端索要验证码的请求后发送验证码,并将验证码和请求中的标识符作为一组数据通过JDBC(Java Data Base Connectivity)记录在Mysql数据库中。然后等web服务器收到客户端提交的验证码后,依照提交请求中的标识符到Mysql数据库中找到对应的验证码,拿此验证码和提交的验证码进行匹配。测试结果表明:此方法有效地解决了使用session记录用户信息的弊端,而且还具有数据保存时间灵活,数据方便于管理,服务器内存占用减少的优点。
The traditional method of recording CAPTCHA(Completely Automated Public Turing test to tell Computers and Humans Apart)exists some problems:If the client is unable to use cooki,correct validation is unable to carry out.So this paper proposed a method of recording CAPTCHA by Mysql. Firstly, this web server generated a CAPTCHA after the client sent the request for CAPTCHA to web server, this CAPTCHA and the identifier in the request stored in the Mysql database by JDBC (Java Data Base Connectivity) as a group of data.After the web server received the submission of CAPTCHA from client,the web server found the corresponding CAPTCHA in the Mysql database in accordance with the identifier in the submission of the request.Test results show that this method solved the drawbacks of using session to record user information effectively.And it had additional advantages:The data retention time is flexible, convenient for data management, reduce server memory footprint.
出处
《信息通信》
2016年第2期104-106,共3页
Information & Communications