PHP reads the code for cookies set by javascript

  • 2020-03-31 20:37:40
  • OfStack

The following code is given:
 
<script language="JavaScript" type="text/javascript"> 
function setmycookie(name) //Main internal parameters
{ 
$name = "thename"; 
$namev = test.num.value; 
var date = new Date(); 
$livetime = 5*24*3600*1000; 
date.setTime(date.getTime()+$livetime); 
document.cookie =name+"="+$namev+";expires="+date.toGMTString(); 
document.cookie = "uername=sasas;expires="+date.toGMTString(); 
</script> 

That's how it works
Setmycookie (' name '); This sets a cookie named name under the domain name
It's easier to read in PHP.
 
<?php 
$str = $_COOKIE('name');//The parameter inside is the name set above
?> 

Reproduced from 5D happy blog
The following is some supplementary knowledge, in-depth friends can refer to.
(link: #)

Since we did not find a better set of code for the operation functions for js cookies, better content can be referred to in the next article.

Related articles: