Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:23:56+00:00 2026-06-05T07:23:56+00:00

While browsing a website, say www.example.com, it is possible that the user enters some

  • 0

While browsing a website, say http://www.example.com, it is possible that the user enters some subdomain say http://www.sub.example.com

But the base webdomain remains the same.

In my firefox extension, I need to develop a “session” which remains active until a user remains on the same domain.

A simple solution would be to extract the domain from the url first. Then split the string with “.” as token. Thus, we get sub and example for the second case and just example for the second case. I can then compare both. If any are equal, I deduce that the domains are same.

Though this might work, this seems more like a hack and might be prone to false positives/negatives.

Is there a more efficient / cleaner solution to the same problem?

Info: I am using GWT to build the extension

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:23:58+00:00Added an answer on June 5, 2026 at 7:23 am

    You should use nsIEffectiveTLDService, it will handle things like sub.example.co.uk correctly. You can pass an nsIURI instance to nsIEffectiveTLDService.getBaseDomain(), aAdditionalParts parameter should be zero. For http://sub.example.co.uk/foo you will get example.co.uk back – the actual “domain” part. Then you can simply compare the domain names for two URLs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say a user is browsing a website, and then performs some action which changes
While browsing the jquerymobile website, I see some example like disneyworld using jquerymobile technology.
I have a client that wants audio to play while the user is browsing
While browsing the code of some websites I sometimes notice that some JavaScript files
While randomly browsing my website via Google, I noticed that it was showing up
While browsing SO I sometimes see EOFD for example: ftp -vn <$hostname> <<EOFD Yes
i got 'JQuery' is undefined error while browsing the page in IE 6 but
While making some final tests of a class-library that I'm writing for Windows Mobile
I want to use C#/ASP.net to find out whether the user browsing the website
Lately I was pointed to http://opencpu.org/ . Nifty website, but after browsing for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.