Print Page | Close Window

Cookie Domain setting problem

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=30370
Printed Date: 31 March 2026 at 1:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Cookie Domain setting problem
Posted By: fooladi
Subject: Cookie Domain setting problem
Date Posted: 13 June 2012 at 10:19pm
edit: I had this problem but strangely solved.

users generally enter to the forum with "www" for example  www.mysite.com but if they enter by google or somehow  without  "www" they have to re-log in


forum installed in root folder and don't use sub-domain.

I logged in as admin  without www and as testuser with www  in same web browser.

I tried to set Cookie Domain to mysite.com instead to leaving it blank. and also  Cookie Path to /
when tried to logout admin user this error occurred:


Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Response.Cookies(...).Domain'

/functions/functions_common.asp, line 2185

then I went to www.mysite.com and tried  to logout testuser. it remained logged in without receiving any error massage and couldn't logout.


i cleaned  Cookie Domain setting as before and then cleaned all cookies. 
now both with and without www works fine!
Confused
what happened?




Replies:
Posted By: WebWiz-Bruce
Date Posted: 14 June 2012 at 8:38am
A website with www. and without are technically two different domains and so for security reasons a browser would not share cookies between the two domains.

If you have a website that can be reached with www. and without then it is seen as two websites with duplicate content and search engines will mark you down for this.

What you should do is select which domain you want to use with your website, either with the www. or without and then setup a 301 permanent redirect to the correct domain.

For example our domain is http://www.webwiz.net" rel="nofollow - www.webwiz.net , if you try and reach our website using  http://webwiz.net" rel="nofollow - webwiz.net it will redirect to include the www. part.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: fooladi
Date Posted: 14 June 2012 at 3:19pm
thanks for your advice

I can not access to IIS settings
so I try to use this code:

<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>

where and how use this? guess header.asp


Posted By: WebWiz-Bruce
Date Posted: 14 June 2012 at 5:10pm
The best way to do this if you have the IIS Rewrite Mod installed is place the following rewrite rules in your web.config file:-

 <rewrite>
            <rules>
                <rule name="Redirect webwiz.net to www.webwiz.net" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="webwiz.net" />
                    </conditions>
                    <action type="Redirect" url="http://www.webwiz.net/{R:0}" />
                </rule>
            </rules>
</rewrite>

Obviously replace webwiz.net with your own domain.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: fooladi
Date Posted: 14 June 2012 at 6:30pm
thanks but can not use IIS Rewrite Mod.

any way I add this code to header.asp and its works now:

Obviously don't work in localhost

<%
Dim QS
Dim QST
QST = Request.ServerVariables("QUERY_STRING")
IF QST <> "" then
QS = "?" & QST
Else
QS = QST
End if
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
	Response.Status="301 Moved Permanently"
	If Request.ServerVariables("HTTPS") = "off" then
	Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") & QS
	Else if Request.ServerVariables("HTTPS") = "on" then
	Response.AddHeader "Location","https://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") & QS
	End if
	End if
	Response.End
End if
%>



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net