Easy Cross Domain Cookies (Sharing cookies between domains)

I own several websites that need memberships to post comments, and recently I wanted the ability to have a single login - so once the user is logged into one site they are automatically logged into the others.

Ideally, I could just write the login cookies for both domains from one location, or somehow share the same login cookie between the domains - but you quickly come up against browser security which (for good reason) doesn’t allow this sort of thing.

There are plenty of ways of solving this problem - but this is the simplest I could find. It uses an IFrame to set cookies on the foreign domain.

In the example, you have Domain A which the visitor is currently on, and Domain B, which you want to set cookies on.

Add a page ‘FrameLogin.aspx’ to your Domain B website.


Public Partial Class FrameLogin
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sUserID As String

        HttpContext.Current.Response.AddHeader(”p3p”, “CP=\”"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\”"”)

        sUserID = Request.QueryString(”userid”)

        Dim oCookie As New HttpCookie(”UserID”)
        oCookie.Value = sUserID
        oCookie.Expires = DateTime.Now.AddDays(1000)
        HttpContext.Current.Response.Cookies.Add(oCookie)
        oCookie = Nothing

    End Sub

End Class

Note that the p3p header has been added, this is to allow 3rd party cookies.

To call this page, we insert code into the appropriate ‘Login’ function in your Domain A website.


    Private Function Login(ByVal sUserName As String, ByVal sPassword As String) As Boolean
        Dim iUserID As Integer

        iUserID = CheckLoginOKAndGetUserdID(sUserName, sPassword)

        If iUserID <> 0 Then
            Login = True
            Response.Write(”<IFRAME style=’WIDTH:1px;HEIGHT:1px’ src=’http://www.DomainB.com/FrameLogin.aspx’ frameBorder=’0′></IFRAME>”)
        Else
            Login = False
        End If

    End Function

Once the cookie has been set on Domain B I can use it to auto-login my visitors when they get there.

Also: For simplicity, I am using an IFrame to call a page. If I wanted faster execution I could substitute an iHttpHandler for the page.

We Got Domain - over 10,000 aged domains for sale

We Got Domain is a quick site that I built to make buying domains from forums like dnforum, digitalpoint etc easier. It extracts domain names from the sale threads and then finds out extra info like Backlinks, Pagerank, Creation date etc. Domains can only be bought on the forums so hopefully We Got Domain will save time for people buying domains while driving extra traffic to the forums (and they get tons of do-follow links as a small bonus).

The site was partly inspired by a the post Purchasing Domains on EarnersBlog.com as well as Shoemoney Marketplace and bizmp.com

I hope you find the site useful - send me an email if you have any suggestions or improvements.

Your own Lolcats widget (I Can Has Cheezburger?)

OK, I’m the first to admit that the whole lolcats thing might not be for everyone. But it’s for me. If it’s for you, too, then enjoy :)
If you would like this widget on your site/blog, just add the code:
<script src='http://lolcats.com.89.seekdotnet.com' type='text/javascript'></script>
And here’s how it was done:


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sCacheKey As String = "CACHE_ICanHasCheezburger"
        Dim oLolCat As clsLolCat
        Dim sHTML As String        

        oLolCat = CType(Cache(sCacheKey), clsLolCat)        

        If oLolCat Is Nothing Then
            oLolCat = PicAndCaptionGet()
            Cache.Insert(sCacheKey, oLolCat, Nothing, Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration)
        End If        

        sHTML = "<div><a href='" & oLolCat.sLinkURL & "'><img border='0' src='" & oLolCat.sPicURL & "'/></a>"
        sHTML = sHTML & "<div>More at LolCats at <a href='http://icanhascheezburger.com'>I Can Has Cheezburger</a></div></div>"        

        sHTML = "document.write(""" & sHTML & """);"
        Response.Write(sHTML)        

    End Sub

This first part just checks to see if we have the LolCat HTML in the cache. If we don’t then generate the HTML and put it in the cache again. Saves us hitting the http://icanhascheezburger.com site all the time (or in this case, feedburner).


    Private Function PicAndCaptionGet() As clsLolCat
        Dim Http As HttpWebRequest
        Dim sRequestURL As String
        Dim WebResponse As HttpWebResponse
        Dim responseStream As Stream
        Dim Reader As StreamReader
        Dim sText As String
        Dim oRSSDoc As New System.Xml.XmlDocument
        Dim oFirstNode As System.Xml.XmlNode
        Dim oLolCat As New clsLolCat        

        sRequestURL = "http://feeds.feedburner.com/ICanHasCheezburger?format=xml"
        Http = CType(WebRequest.Create(sRequestURL), HttpWebRequest)
        Http.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")
        WebResponse = CType(Http.GetResponse(), HttpWebResponse)
        responseStream = WebResponse.GetResponseStream        

        If (WebResponse.ContentEncoding.ToLower().Contains("gzip")) Then
            responseStream = New GZipStream(responseStream, CompressionMode.Decompress)
        ElseIf (WebResponse.ContentEncoding.ToLower().Contains("deflate")) Then
            responseStream = New DeflateStream(responseStream, CompressionMode.Decompress)
        End If        

        Reader = New StreamReader(responseStream, Encoding.Default)
        sText = Reader.ReadToEnd()
        WebResponse.Close()
        responseStream.Close()        

        oRSSDoc.LoadXml(sText)
        oFirstNode = oRSSDoc.SelectSingleNode("//item")
        oLolCat.sCaption = oFirstNode("title").InnerText
        oLolCat.sLinkURL = oFirstNode("link").InnerText
        oLolCat.sPicURL = oFirstNode("media:content").Attributes("url").Value        

        PicAndCaptionGet = oLolCat
    End Function        

End Class        

Public Class clsLolCat
    Public sPicURL As String
    Public sCaption As String
    Public sLinkURL As String
End Class

This is the code that visits the icanhascheezburger RSS feed and extracts the latest post details. This is all pretty simple stuff, with one cool bit that takes care of the gzip compression that is on the feed. Full credit must go to Rick Strahl for his post talking about gzip: http://www.west-wind.com/WebLog/posts/102969.aspx

Aussie Estate Agents fight Google in Court (and get what they want, sorta)

I noticed in the paper over the weekend that two Melbourne real estate agents sought legal action in December to force Google to not display posts from a certain blog when their names were ‘googled’. The blog posts apparently showed the agents (Paul Castran and Mark Forytarz) in a bit of a bad light - suggesting one bullied a mentally disabled man into selling his house to earn the agent commission and that the other agent participated in illegal dummy bidding. Interestingly, there was no legal action brought against the blogger who wrote the posts. Also, the newspaper article stated that the posts were not removed from the Google index.

Suing Google has been tried several times before, and rarely goes well, but when I did a search the agents names:
http://www.google.com.au/search?hl=en&q=mark+forytarz&btnG=Google+Search&meta=

The defamatory article is not there, and there is this line at the bottom of the page:
In response to a legal request submitted to Google, we have removed 1 result(s) from this page. If you wish, you may read more about the request at ChillingEffects.org.
Notice that the search was done in google.com.au, if you do it in google.com then the defamatory blog post is the first result (though perhaps this will be gone soon, too).

So what caused what here? Did legal action have no effect as claimed by the newspaper? Did the two agents just approach google through other channels (similar to a DMCA takedown)? Given that the initial action reportedly failed, did the recent publicity have anything to do with google removing the blog posts?

But now the posts have been removed from google.com.au, everything is fine for the real estate agents, right?
Not quite.
Now, if you search for ‘Paul Castran’ the #2 result is Paul Castran Wins Today’s Stupid Prize!. Time for more legal action? :)

Using Google Translate to generate new content from old

All the search engines love unique content, but rewriting articles is such hard work… there has to be an easier way…

This is a simple method that alters your original text, while still remaining (relatively) readable.

Feed your original text into Google Translate, going from English to French. Then take the French text and translate it back to English.

Original
All popups are bad news, right? Nothing gets rid of visitors faster than a crappy ad for casinoviagraporn getting in their face.

But what about visitors that found your site through a search engine, spend 5 seconds on 1 page of your site & then press the back button?

They didn’t find what they want.
They aren’t coming back.
Don’t they deserve some popup love?

New
All of the pop-ups are bad news, right? Nothing gets rid of visitors faster than a crappy ad for casinoviagraporn get in their face.

But what about the visitors found your site through a search engine, spend 5 seconds on 1 page on your site and then press the button back?

They did not find what they want.
They are not to return.
Do they not deserve some popup love?

Voila! What is old is new again :)

Bargains to be had at DNForum

I was just checking through DNForum for cheap domain names and I noticed that a PR8 domain with 293,000 backlinks was just sold for around $200!!

That has got to be the bargain of the year! I’m kicking myself that I missed it.

On the other hand, don’t believe everything:
There is this sales thread on sitepoint, for a domain listed as PR6 and 1800+ backlinks. On further inspection of the:
PR
and the
backlinks
maybe it isn’t quite such a good deal.

AGLOCO goes belly up

I just got this email.

Dear Gath,

We would like to update you on the status of AGLOCO’s operations. We continue to believe in the AGLOCO concept, but our revenue is currently not sufficient to give Members a meaningful distribution. And though there are increases in membership, the resulting revenue is not enough to support operating costs. As a development team we are unable to continue to use our savings to fund the operations. If any Member would like to pursue continuing the operations of AGLOCO, you may contact us at agloco1@live.com .

We would like to thank every Member for supporting our effort to bring a piece of the Internet directly to the user. We hope that we can find a way to keep the operations going.

AGLOCO Development Team

So, it looks like all the people who said ‘If it seems too good to be true….’ were right. Looks like I’m going to cancel my order for the ferrari.

Need more traffic? Blog MatchUp is coming!

I’ve been a bit quiet lately, but thats just because I’ve been working on my latest project - and it’s almost ready.

Blog MatchUp allows you to compete with other blogs for bragging rights over who has the most traffic. But as everyone saw from the ShoeMoney vs john Chow competition, everyone is a winner with more traffic.

At the moment Blog MatchUp is taking registrations, but should be ready to launch beta testing within a week.

Cheers,
Gath

Giving Blogrush a go

So I was reading over on ShoeMoney’s blog & noticed something about a new traffic exchange program - Blogrush.

It’s a bit different from the usual traffic/banner exchange programs in that it displays the latest blog posts from other blogs in related niches. It’s brand new (though a lot of the big blogs - shoemoney, john chow & dosh dosh have already got it) so I thought I would give it a try & let you all know how I go.

Adding the widget is easy - just past the javascript straight onto your page. Since it is javascript you don’t have to worry about adding ‘nofollow’ or any of that junk.

They are expecting to make a lot of changes in the next few weeks - one of the first things that I hope they add is the ability to customise how the widget looks. At the moment, it looks like the default theme is set to ‘fugly’, but maybe thats just my taste.

If you like the idea, then sign up to Blogrush & let’s exchange some traffic! :)

Draggable Marker Google Maps Demo

So you’ve been checking out my previous posts on Google Maps and Draggable Markers, and it would be nice to have a demo so you can see the draggable markers in action.

Check this out:

And the code as well? Here is the source for the Google Maps Demo