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 8415229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:23:04+00:00 2026-06-10T01:23:04+00:00

I already have a script that check for the cookies existence, but i need

  • 0

I already have a script that check for the cookies existence,
but i need it to get the cookies value so i can use it in a url like this:

var lang = cookievalue;
location.replace(window.location.protocol+"//"+document.domain+"/"+cookievalue+window.location.pathname);

so what would be the easiest way to simply get the value of a cookie through javascript, everything i’ve looked for seems to involve spliting the value and stuff,w hich is not necesary since theres simply only one value (en,fr,es etc)

  • 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-10T01:23:05+00:00Added an answer on June 10, 2026 at 1:23 am
    function getCookieValue(key) {
      var cookies = document.cookie.split('; ');
      for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) {
        if (decode(parts.shift()) === key) {
          return decode(parts.join('='));
        }
      }
      return null;
    }
    
    function decode(s) {
      return decodeURIComponent(s.replace(/\+/g, ' '));
    }
    

    Then, to get a value for a cookie named my_cookie_name, you would use getCookieValue('my_cookie_name').

    Also as an alternative, you can use the jquery-cookie plugin. It’s very simple to use ($.cookie('my_cookie_name')) and lightweight.

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

Sidebar

Related Questions

I have a script that is intended to check whether some value (e.g. option
In my login script I have put a checkbox that people can check if
I have created a script that reads from a CSV (or other dataset, but
Hi all I have the following SQL Server 2008 script that will check if
I have a script that pulls in meta data from a list of URL's
I am trying to create a password check script. I already have checks for
I have a simple script, which tries to kill an already running process. I
I have a mySQL database and I have a Perl script that connects to
I have a script that I only want to be running one time. If
I have a script that uses autoload to load classes that aren't found. I

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.