<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Securing_cookie_to_one_IP</id>
		<title>Securing cookie to one IP - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Securing_cookie_to_one_IP"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_cookie_to_one_IP&amp;action=history"/>
		<updated>2026-04-20T14:46:21Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_cookie_to_one_IP&amp;diff=24506&amp;oldid=prev</id>
		<title>Clickfind: New page: '''The idea is to make sure a cookie can only be used by the user who it was intended for.''' In other words, if a hacker gained access to the cookie he/she would not be able to use it.  T...</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_cookie_to_one_IP&amp;diff=24506&amp;oldid=prev"/>
				<updated>2008-01-15T22:26:52Z</updated>
		
		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;The idea is to make sure a cookie can only be used by the user who it was intended for.&amp;#039;&amp;#039;&amp;#039; In other words, if a hacker gained access to the cookie he/she would not be able to use it.  T...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''The idea is to make sure a cookie can only be used by the user who it was intended for.'''&lt;br /&gt;
In other words, if a hacker gained access to the cookie he/she would not be able to use it.&lt;br /&gt;
&lt;br /&gt;
The following code samples are for ColdFusion MX, but the principle can easily be used in other languages.&lt;br /&gt;
&lt;br /&gt;
1. when the user starts a session, set a cookie named &amp;quot;hash&amp;quot; with a hash value of the remote IP address and a secret string, for example &amp;quot;s3cr375tr1ng&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2. upon each following request made, the application checks whether the cookie still exists, and whether the value still matches the remote IP&lt;br /&gt;
&lt;br /&gt;
If the values do not match, then you'd delete the rest of the cookie values and require them to be reset.&lt;br /&gt;
&lt;br /&gt;
'''Now for the ColdFusion code'''&lt;br /&gt;
&lt;br /&gt;
We're assuming you're using jsessionid because they expire when the browser closes, and ColdFusion MX&lt;br /&gt;
&lt;br /&gt;
In onSessionStart we set the following cookie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfcookie &lt;br /&gt;
	name=&amp;quot;hash&amp;quot; &lt;br /&gt;
	value=&amp;quot;#hash( cgi.remote_addr &amp;amp; &amp;quot;s3cr375tr1ng&amp;quot; )#&amp;quot; &lt;br /&gt;
	domain=&amp;quot;.clickfind.com.au&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In onRequestStart we have the following code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif compareNoCase( cookie.hash, hash( cgi.remote_addr &amp;amp; &amp;quot;s3cr375tr1ng&amp;quot; ) ) neq 0 &amp;gt;&lt;br /&gt;
&amp;lt;!--- IP is not the same anymore, do what needs to be done here ---&amp;gt; &lt;br /&gt;
&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above idea was created to secure [http://www.clickfind.com.au www.clickfind.com.au], but we like sharing ;-)&lt;br /&gt;
If you have any improvements or suggestions, please do let us know [http://www.clickfind.com.au/contact-us.cfm contact us]&lt;/div&gt;</summary>
		<author><name>Clickfind</name></author>	</entry>

	</feed>