Jump to content

Changing PHP Code Into JS Code


Xtremer360

Recommended Posts

I'm trying to change:

 

if(isset($_COOKIE['page'])) { ajaxpage("$_COOKIE['page']", "content);
}
else {
ajaxpage("default", "content");
}

 

into its javascript equivilent for the page I have and me nor the person that gave me the code knows how.  Does anyone else?

Link to comment
https://forums.phpfreaks.com/topic/137317-changing-php-code-into-js-code/
Share on other sites

Try that..

 

if (document.cookie.match('page=[\w][\w\-\.]+;') != null) {

 

This will also prevent any XSS injection, make sure the page name only includes chars: 0-9 a-z A-Z _ - . and only starts with 0-9 a-z A-Z _

 

* Not tested *

 

A

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.