<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cookie secure &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/cookie-secure/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Mon, 24 Apr 2023 06:00:29 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>cookie secure &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>加密的階段作業 (SSL) Cookie 中遺漏安全屬性</title>
		<link>https://noter.tw/11094/%e5%8a%a0%e5%af%86%e7%9a%84%e9%9a%8e%e6%ae%b5%e4%bd%9c%e6%a5%ad-ssl-cookie-%e4%b8%ad%e9%81%ba%e6%bc%8f%e5%ae%89%e5%85%a8%e5%b1%ac%e6%80%a7/</link>
					<comments>https://noter.tw/11094/%e5%8a%a0%e5%af%86%e7%9a%84%e9%9a%8e%e6%ae%b5%e4%bd%9c%e6%a5%ad-ssl-cookie-%e4%b8%ad%e9%81%ba%e6%bc%8f%e5%ae%89%e5%85%a8%e5%b1%ac%e6%80%a7/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Tue, 14 Mar 2023 02:51:17 +0000</pubDate>
				<category><![CDATA[網頁前端]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google 分析]]></category>
		<category><![CDATA[加密的階段作業 (SSL) Cookie 中遺漏安全屬性]]></category>
		<category><![CDATA[cookieFlags]]></category>
		<category><![CDATA[cookie secure]]></category>
		<category><![CDATA[_ga]]></category>
		<guid isPermaLink="false">https://noter.tw/?p=11094</guid>

					<description><![CDATA[<p>加密的階段作業 (SSL) Cookie 中遺漏安全屬性 。小蛙負責的網站必須要通過資訊安全相關掃描，否則就會被下架，因此每隔一段時間就會掃描一次看看有沒有什麼問題，通常都是掃出一些不大不小的問題，例如這個 加密的階段作業 (SSL) Cookie 中遺漏安全屬性。</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/11094/%e5%8a%a0%e5%af%86%e7%9a%84%e9%9a%8e%e6%ae%b5%e4%bd%9c%e6%a5%ad-ssl-cookie-%e4%b8%ad%e9%81%ba%e6%bc%8f%e5%ae%89%e5%85%a8%e5%b1%ac%e6%80%a7/" data-wpel-link="internal">加密的階段作業 (SSL) Cookie 中遺漏安全屬性</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>小蛙負責的網站必須要通過資訊安全相關掃描，否則就會被下架，因此每隔一段時間就會掃描一次看看有沒有什麼問題，通常都是掃出一些不大不小的問題，例如這個 <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">加密的階段作業 (SSL) Cookie 中遺漏安全屬性</mark></strong>。</p>



<span id="more-11094"></span>



<p>上一次掃出來的時候已經修正過了，這次加了一些功能後又出現，下圖是安全掃描報告，看到 _ga, _gid 之類的很快就知道是使用 Google 分析 (Google Analytics) 造成的。</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" src="https://lh3.googleusercontent.com/pw/AMWts8CpWO6L1Qe5Nsh4CCbvsy2_g-i-g0NuZANVGH6eae8A8LugZUn96qHAZeKNYKrp-QNQ69xJnuT9e_4BrR3GNOSy9RxUVNpU9YFrCm7Obj0aWSBglx7jyqL0bfYdDFNZc12PNmovWU7tfBs5oHy8XvMD=w800-h288-rw" alt="加密的階段作業 (SSL) Cookie 中遺漏安全屬性" title="加密的階段作業 (SSL) Cookie 中遺漏安全屬性"></figure></div>


<p>要修正這個嚴重性被標示為「中」的問題很簡單，只要到載入及初始化 Google 分析的部份，例如小蛙找到其中一個頁面 Google 分析的載入有這段</p>



<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">ga('create', 'UA-xxxxxxxx-x', 'auto');</pre>



<p>這時候要用到 Google 分析提供的 cookieFlags，把上述設定改成 </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">ga('create', 'UA-xxxxxxxx-x', {'cookieFlags': 'SameSite=None; Secure'});</pre>



<p>就可以囉 ~ 更多 cookieFlags 的設定可參考：<a href="https://www.ichdata.com/cookieflags-field-google-" target="_blank" rel="noreferrer noopener ugc nofollow external" data-wpel-link="external" class="wpel-icon-right">Google Analytics设置cookieFlags &#8211; GA 小站analytics.html<span class="wpel-icon wpel-image wpel-icon-6"></span></a>，F12 看看設定前跟設定後的差別。</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://lh3.googleusercontent.com/pw/AMWts8Cq_ziC0VswS6rCRJKZYvWfV4uGDD9mzuNKwnj--5cGPj5aJVFlKFGXnHTAqmn6JsHYY4sVIXQNct366HaThiUPcTUfy44LqKj2D7IKnrVfmEYJk5Umm8s_ng41YtLw5uoJP9IipOvVKs6O8M2LmfyO=w1151-h117-rw" alt="cookieFlags secure 設定前" title="加密的階段作業 (SSL) Cookie 中遺漏安全屬性"><figcaption>cookieFlags secure 設定前</figcaption></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="https://lh3.googleusercontent.com/pw/AMWts8CEoTm4A21-ms2U2YLb7lzDJ7-x0LlwO20E_LIBk8pprJ0AHGoU_6JHjsAbbUsMbL_OLvX-5fW3BHKaPIZtpLfBBN-fCA7J78nzueG17knPiZXlhGM0N5bO_eKovzIKdAkFlEOJnY-bmJatVdhwTEuL=w1153-h117-rw" alt="cookieFlags secure 設定後" title="加密的階段作業 (SSL) Cookie 中遺漏安全屬性"><figcaption>cookieFlags secure 設定後</figcaption></figure>



<p>打完收工～！再次送掃！站上還有其他不錯的 <a href="https://noter.tw/category/share/trick/" target="_blank" rel="noreferrer noopener" data-wpel-link="internal">技巧分享</a> 喔～</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/11094/%e5%8a%a0%e5%af%86%e7%9a%84%e9%9a%8e%e6%ae%b5%e4%bd%9c%e6%a5%ad-ssl-cookie-%e4%b8%ad%e9%81%ba%e6%bc%8f%e5%ae%89%e5%85%a8%e5%b1%ac%e6%80%a7/" data-wpel-link="internal">加密的階段作業 (SSL) Cookie 中遺漏安全屬性</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/11094/%e5%8a%a0%e5%af%86%e7%9a%84%e9%9a%8e%e6%ae%b5%e4%bd%9c%e6%a5%ad-ssl-cookie-%e4%b8%ad%e9%81%ba%e6%bc%8f%e5%ae%89%e5%85%a8%e5%b1%ac%e6%80%a7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
