Table of Contents
回复内容:
Home Backend Development PHP Tutorial 网站验证码一般放在服务器端什么地方?为什么?

网站验证码一般放在服务器端什么地方?为什么?

Jun 06, 2016 pm 08:46 PM
.net java php programmer

网站验证码一般放在服务器端什么地方?为什么?java php .net做的网站验证码都放同一个地方吗?

回复内容:

网站验证码一般放在服务器端什么地方?为什么?java php .net做的网站验证码都放同一个地方吗?

验证码 放在服务器的什么地方?各个语言放的地方一样吗?

首先问题我不是很能理解,我通过我的理解试着解答

验证码 -> captcha 的生成,必然是在服务器端生成的,会储存为一个图片放在服务器的一个目录下,这些文件可以通过生成时间命名,然后固定一段时间后自动删除

我还见过有人做假的验证码,所谓假的验证码就是在client side用js生成验证,而不是到服务器端进行验证。java php .net都有现成的captcha生成方法,不用自己写了,直接用就行,配置一下目录,字符集和captcha类型就可以了。

如果回答了您的问题请采纳吧,或者点个赞也行啊

一般是存在session里的

简单点说,验证码生成的时候,先生成随机字符串,这个变量以session的形式存储在服务器内存中,与客户端session-id对应,然后使用GDI+等绘图方式绘制成图片然后输出到页面上,服务端不保存图片只记录字符串用于验证

一般都用 session,可以使用默认的临时文件,也有把 session 放在数据库或内存里、

  1. 客户端访问网站
  2. 服务端生成Session标记,并将Session标记返回给客户端,一般通过在响应中输出在Cookie中实现。
  3. 客户端携带Session标记访问验证码网址
  4. 服务端生成随机码,并将随机码渲染成图片输出,随机码(非图片)存储与内存中的数据结构,一般是字典,只要维护要易失行即可。
  5. 客户端携带Session标记回传用户输入的验证码
  6. 服务端根据Session通过字典查找之前生成的随机码并和客户端回传的验证码进行比较。

看到了吗?服务端并不会保存验证码图片,仅仅在短时间内保存验证码的值。因为保存图片对服务器并没有意义,而且会增加服务器的IO和存储负担。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1252
24
C# as a Versatile .NET Language: Applications and Examples C# as a Versatile .NET Language: Applications and Examples Apr 26, 2025 am 12:26 AM

C# is widely used in enterprise-level applications, game development, mobile applications and web development. 1) In enterprise-level applications, C# is often used for ASP.NETCore to develop WebAPI. 2) In game development, C# is combined with the Unity engine to realize role control and other functions. 3) C# supports polymorphism and asynchronous programming to improve code flexibility and application performance.

Deploying C# .NET Applications to Azure/AWS: A Step-by-Step Guide Deploying C# .NET Applications to Azure/AWS: A Step-by-Step Guide Apr 23, 2025 am 12:06 AM

How to deploy a C# .NET app to Azure or AWS? The answer is to use AzureAppService and AWSElasticBeanstalk. 1. On Azure, automate deployment using AzureAppService and AzurePipelines. 2. On AWS, use Amazon ElasticBeanstalk and AWSLambda to implement deployment and serverless compute.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

What does 'platform independence' mean in the context of Java? What does 'platform independence' mean in the context of Java? Apr 23, 2025 am 12:05 AM

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

C# .NET: Building Applications with the .NET Ecosystem C# .NET: Building Applications with the .NET Ecosystem Apr 27, 2025 am 12:12 AM

How to build applications using .NET? Building applications using .NET can be achieved through the following steps: 1) Understand the basics of .NET, including C# language and cross-platform development support; 2) Learn core concepts such as components and working principles of the .NET ecosystem; 3) Master basic and advanced usage, from simple console applications to complex WebAPIs and database operations; 4) Be familiar with common errors and debugging techniques, such as configuration and database connection issues; 5) Application performance optimization and best practices, such as asynchronous programming and caching.

H5: Key Improvements in HTML5 H5: Key Improvements in HTML5 Apr 28, 2025 am 12:26 AM

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

See all articles