Do I usually use cookies or sessions to write login. php? How to solve

Source: Internet
Author: User
Do I usually use cookies or sessions to write login. php? I don't know which one to choose. Can you tell me what you use ?, SESSION, SESSION security, high pressure on the server ., Session better !!!, When important information is run in session, such as login information and other server segments, do you usually use cookies or sessions to write login. php during session status?
I don't know which one to choose.
Can you tell me what you use?

------ Solution --------------------
SESSION
------ Solution --------------------
SESSION Security puts a lot of pressure on servers.
------ Solution --------------------
The session is better !!!
------ Solution --------------------
Important Information uses sessions, such as logon information.
The server segment is running and memory is occupied during the session status. When it is disabled, the memory is released.
Due to the small amount of information, session is generally used for security considerations.


Cookies for non-important information


------ Solution --------------------
Session
------ Solution --------------------
Session is good. cookies are mainly used on clients. they are not good and dangerous.
------ Solution --------------------
Session is not a very popular website.
Will not reflect the pressure on the server
------ Solution --------------------
Hybrid use
Using cookies to control the time of refreshing sessions ensures security and does not put pressure on the server.
------ Solution --------------------
Occasionally use session, without cookie.

------ Solution --------------------
We can use cookies to simulate sessions and encrypt data in some way.
$ Chkcode = md5 ($ row ['id']. $ row ['username']. $ activetime. $ ['auth _ Code']);
Setcookie ("member_id", $ row ['id'], null, "/", null );
Setcookie ("username", $ row ['username'], null, "/", null );
Setcookie ("activetime", $ activetime, null, "/", null );
Setcookie ("chkcode", $ chkcode, null, "/", null );
------ Solution --------------------
SESSION is an application of COOKIE.

It is easier for medium and small sites to directly use sessions for big sites and multi-sites. the COOKIE is better.
------ Solution --------------------
"SESSION is a COOKIE application and cannot be equivalent to a comparison"

For session, there are three methods to save the client id: 1. cookie 2.url 3. hidden field
Cookie is one of the containers of a session.
In contrast, the session is highly secure because it is stored on the server.
To ensure high security, you must encrypt/decrypt the data.
Session stores a large amount of data. of course, this also consumes resources on the server, and the maximum size of cookie data stored is 4 kB.
------ Solution --------------------
Even session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.