PHP disables COOKIE to get SESSION

time:15-12-28 forum:PHP tools and code
  http://blog.sina.com.cn/s/blog_4dd4753901017jdl.html


we know that when client browsers are banned from COOKIE, there is no way to use the server side. Because the server - side SESSION is to distinguish different users' SESSION through SESSIONID, the SESSIONID is passed to the server side through the client's COOKIE, more strictly speaking, because after PHP uses the session_start () statement, it sends a header information to the client, which specifies the SESSION meeting. SESSIONID of the word, this SESSIOID is stored in the COOKIE of the client. After COOKIE is banned, of course, SESSIONID can not be saved.

below is the header information of the output of session_start ():

[code]Content-type: text/html
X-Powered-By: PHP/4.3.3
Set-Cookie: PSD=9b577c86baea8a15ebe15b220ee1e180; path=/
Pragma: no-cache
[/code]
now you can make sure that you can't use SESSION after the COOKIE is banned. In this case, the customer is to prohibit COOKIE, and we have to ensure that this part of the user can be used normally, what should we do? The solution is to use the output_add_rewrite_var function of PHP.

this is not afraid of disabling COOKIE, because SESSIONID will automatically follow URL and FORM will appear HIDDEN value of SESSIONID. It is OK to use SESSION at the server side as usual.

Test Code: test.php

[code].lt; php
session_start ();
$_SESSION.#91;'test'.#93;'test'.#93;
output_add_rewrite_var. T; php
session_start ();
print_r ($_SESSION);

.Gt; [/code]

prev:Analysis of PHP cookie and session next:JS array usage description
post comment
Notice



approved   Utility tools or components, framewo...   Mother recorded the 44 weeping of he...   The 71 moments of survival of the po...   Post retirement pension crisis: perh...   How much do you know about the histo...
rand   Chinese character intercepting funct...   Converting strings to arrays with PH...   PHP removes the last character subst...   PHP extracts the numbers in a string   PHP determines to compare the data i...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com