0

I want to Get the cookie value from the browser. Bind it it to a variable or i could use it directly.

Example: In php i can receive the cookies like

if ((isset($_COOKIE['tenant']))) {
    $cookie_name = $_COOKIE['tenant'];
}

Similarly i could do this and want to assign the cookie value to another variable

1 Answers1

0

Use javascript document.cookie. PHP run on the Server side. Javascript and Jquery on Client side (Browser), but only for own Cookies, not for cookies from another sites.

Here is similar Question

There is way how to add Cookies into PHP in JS, but I think it´s not secure.

Jan Sršeň
  • 1,045
  • 3
  • 23
  • 46
  • Hi Jan Sršeň, **i want to do this in .htaccess file. ** Please reply if you able to do the same concept which i did in php on **htaccess apache ** – Poongkundran Soundarajan Jul 19 '17 at 06:18
  • Maybe try [Apache HttpClient](http://hc.apache.org/httpclient-3.x/cookies.html) or StackOverflow old posts for example: [Stack](https://stackoverflow.com/questions/19382160/htaccess-compare-cookie-value-and-redirect-if-evaluation-returns-true-false) or [Stack](https://stackoverflow.com/questions/24245096/how-to-get-cookie-set-by-htaccess-file-on-first-load) or edit Cookie with `RequestHeader edit Cookie "^(.*?)ANY_COOKIE=.*?;(.*)$" $1$2`, but I dont try it – Jan Sršeň Jul 19 '17 at 06:26