Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Javascript Help on URL Query

I am familiar with PHP but need a solution that is in Javascript instead. I cannot use PHP in this case. Can someone help me convert this from PHP to Javascript?

My goal is to determine what "a" is in the URL first. If not available, look for a cookie. If neither available then set a default value in the cookie.

mydomain.html?a=test2

//Determine Variable A
if (isset($_GET['a'])) {
    $a=$_GET['a'];
    setcookie("a",$a, time()+86400);  /* expire in 60 days */
} elseif (empty($_COOKIE['a'])){
    $a="test1";
    setcookie("a",$a, time()+86400);  /* expire in 60 days */
} else {
    $a=$_COOKIE['a'];
}

Thank you very much!!!

Susan

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!