XSS attacks when setting cookies

Source: Internet
Author: User
Tags send cookies

XSS attacks when setting cookies

We all know that many XSS attacks aim to obtain users' cookie information. The most common method is to transmit cookies to other servers by setting src in js.

So how can we prevent js from getting cookies? Here is a simple method. Taking PHP as an example, we seldom write the following parameters when setcookie, and basically write the data to the date, take a look at its parameter settings.

Bool setcookie (string $ name [, string $ value [, int $ expire = 0 [, string $ path [, string $ domain [, bool $ secure = false [, bool $ httponly = false])

 

What is the next $ httponly? They actually set to send cookies only under http. For example, if $ httponly is set to true, they cannot be obtained when js is used to obtain cookies. You can try it, although not all browsers support it and there are other ways to obtain cookies, it can reduce some security vulnerabilities.

 

Welcome to the discussion!

Related Article

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.