Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Cookie Domain setting problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Cookie Domain setting problem

 Post Reply Post Reply
Author
fooladi View Drop Down
Groupie
Groupie


Joined: 21 July 2003
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote fooladi Quote  Post ReplyReply Direct Link To This Post Topic: Cookie Domain setting problem
    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?



Edited by fooladi - 13 June 2012 at 10:27pm
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (1) Thanks(1)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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 www.webwiz.net, if you try and reach our website using webwiz.net it will redirect to include the www. part.
Back to Top
fooladi View Drop Down
Groupie
Groupie


Joined: 21 July 2003
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote fooladi Quote  Post ReplyReply Direct Link To This Post 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


Edited by fooladi - 14 June 2012 at 3:28pm
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
fooladi View Drop Down
Groupie
Groupie


Joined: 21 July 2003
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote fooladi Quote  Post ReplyReply Direct Link To This Post 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
%>


Edited by fooladi - 14 June 2012 at 10:08pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.