In a PHP call Window.location.href jump after the jump in the page after the session failure can not be used, how to solve
Reply to discussion (solution)
Jump to where?
Your code
Jump to where?
Your code
$url = "main.php"; window.location.href= ' $url ';
That's it
You don't have a session set in your code.
Where did the session go missing?
You don't have a session set in your code.
Where did the session go missing?
There is a setup ah, in front of the code I thought you wanted to see how this jumps.
is to set the session=[' check ' on the front]=true
And then at this point in the back, I can't read this truth.
You're not writing this wrong?!
session=[' Check ']=true
Is that what the Martians are writing?
You're not writing this wrong?!
session=[' Check ']=true
Is that what the Martians are writing?
It's not a problem in the code. I can read the contents of the session in the page without jumping.
But on the page that jumps to, I can't get to the session.
I don't want to tell you anything.
The premise of discussion is sincerity, the basis is reciprocity
I don't want to tell you anything.
The premise of discussion is sincerity, the basis is reciprocity
This is a very simple question for me. When you use Window.location.href to jump pages in PHP, the pages you jump to and the original page cannot be shared.
This is the nature of the session, I also found in other places this problem but there is no clear solution, not to say that my code has a problem, is not the problem of the code, I think I have put my problem has been explained, that is, when using the jump page, the original page of the session For the page after the jump is unreadable, so how to solve.
Besides, I think I'm sincere enough, and I've already told you everything I know.
The correct wording of the Session is
Session_Start ();
$_session[' favcolor '] = ' green ';
$_session[' animal ' = ' cat ';
$_session[' time ' = time ();
Like this.
Different domains can cause the session to change. Here are the examples to give the JSP, a look to understand, although you use PHP, but the idea is the focus.
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<%
String jsessionid = Request.getsession (). GetId ();//Gets the current jsessionid (whether from the primary domain or the two-level domain access Generation)
Cookie cookie = new Cookie ("Jsessionid", Jsessionid);
Cookie.setdomain (". test.com"); The key here is to set the cookie as the primary domain access to ensure that the value of the cookie is available between domains, ensuring that the session is unified
Response.addcookie (cookie); Returning cookies to the client
Request.getrequestdispatcher ("indes.jsp"). Forward (request, response);
%>
Reference page
Http://www.cnblogs.com/nicholas_f/archive/2010/11/05/1869811.html
The correct wording of the Session is
Session_Start ();
$_session[' favcolor '] = ' green ';
$_session[' animal ' = ' cat ';
$_session[' time ' = time ();
Like this.
Different domains can cause the session to change. Here are the examples to give the JSP, a look to understand, although you use PHP, but the idea is the focus.
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<%
String jsessionid = Request.getsession (). GetId ();//Gets the current jsessionid (whether from the primary domain or the two-level domain access Generation)
Cookie cookie = new Cookie ("Jsessionid", Jsessionid);
Cookie.setdomain (". test.com"); The key here is to set the cookie as the primary domain access to ensure that the value of the cookie is available between domains, ensuring that the session is unified
Response.addcookie (cookie); Returning cookies to the client
Request.getrequestdispatcher ("indes.jsp"). Forward (request, response);
%>
Reference page
Http://www.cnblogs.com/nicholas_f/archive/2010/11/05/1869811.html
You know, I understand, but I also want to ask how the WINDOW.LOCATION.HREF jump was implemented.
Your attitude is sincere, but you and I have the information (you do not want to provide) is not the right to wait
There is a problem with your code, so there will be false performance!
Session_target.
The fact is there, say no more!
Your attitude is sincere, but you and I have the information (you do not want to provide) is not the right to wait
There is a problem with your code, so there will be false performance!
Session_target.
The fact is there, say no more!
index.php:
main.php:
My one is about the same as yours, but the output is a null value.
Your attitude is sincere, but you and I have the information (you do not want to provide) is not the right to wait
There is a problem with your code, so there will be false performance!
Session_target.
The fact is there, say no more!
index.php:
main.php:
My one is about the same as yours, but the output is a null value.
There's a piece of code that's inverted, it's assigned first.
Your attitude is sincere, but you and I have the information (you do not want to provide) is not the right to wait
There is a problem with your code, so there will be false performance!
Session_target.!--? Phpsession_start ();p rint_r ($_session);
The truth is there, say no more!
and then I changed it as you did
index.php
!--? php session_start ( ); $_session["Check"]=1;print_r ($_session); echo "location= ' session_target.php ' ";?
session_target.php:
!--? Phpsession_start ();p Rint_r ($_ses SION);? -->
also output to null
this is yours! Clearly written wrong, not admit
$_session["check"]=true;
should write
$_session["Check"]=true;
The variable name for PHP is case-sensitive
this is yours! Clearly written wrong, not admit
$_session["check"]=true;
should write
$_session["Check"]=true;
The variable name for PHP is case-sensitive
Oh oh oh oh, I'm sorry for the delay. Thank you so much for your time.