Home  >  Article  >  Backend Development  >  javascript - Sina Cloud Server can only use form to request session, but ajax cannot request it??

javascript - Sina Cloud Server can only use form to request session, but ajax cannot request it??

WBOY
WBOYOriginal
2016-09-11 11:34:091322browse

When writing the php verification code page, I stored the php file on the Sina cloud server. I thought about using ajax request session in the javascript page to verify the verification code. I feel that this method should be feasible, but in reality During the operation, I found that the session retrieved using ajax was always empty and was not requested. One of the reasons was that the code was written incorrectly. I pondered hard and looked it up in various ways. Finally, I found that netizens said that Sina Cloud could not save the session. , but when I use form to make a request, I can get the session value. Why is this? Please solve...

Reply content:

When writing the php verification code page, I stored the php file on the Sina cloud server. I thought about using ajax request session in the javascript page to verify the verification code. I feel that this method should be feasible, but in reality During the operation, I found that the session retrieved using ajax was always empty and was not requested. One of the reasons was that the code was written incorrectly. I pondered hard and looked it up in various ways. Finally, I found that netizens said that Sina Cloud could not save the session. , but when I use form to make a request, I can get the session value. Why is this? Please solve...

If you don’t use a framework, there must be session_start() at the front of the PHP file, and then $_SESSION will work in the file

<code><?php
session_start();</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn