PHP reads the cookie code set in Javascript

Source: Internet
Author: User

Below Code: Copy codeThe Code is as follows: <script language = "JavaScript" type = "text/JavaScript">
Function setmycookie (name) // Main Parameter
{
$ 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>

The usage is like this.
Setmycookie ('name'); in this way, a cookie named name is set under the domain name.
PHP is easier to read.Copy codeThe Code is as follows: <? PHP
$ STR = $ _ cookie ('name'); // The parameter in it is the name set above.
?>

Reposted from 5d happy blog
Below are some supplementary knowledge. For more information, see.
Set and read the JavaScript code of the cookie

Since we have not found a good set of operation function code for JS cookies, for better content, refer to the nextArticle.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.