473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question on Session

Hi all!

I am a newbie in PHP and I have a question on using $_SESSION.

To keep it short, here is the code:

A.php:
<?php
if($_POST['username'] == 'USER' && $_POST['password'] == 'PWD'){
$_SESSION['isLogin'] = 1;
?>
<script language="javascript">
window.location.href="B.php";
</script>
<?php
}
?>

B.php:
<?php
print $_SESSION['isLogin'];
?>

Assume username and password is correct, but B.php show NOTHING!!!
That is, the $_SESSION haven't passed the value from one page to the
other page...

In php.ini: register_globals = On

My question is: how to pass the value from one page to another, without
using $_POST or some other things?

Thanks in advance.

Oct 4 '05 #1
3 1423
al********@gmail.com wrote:
Hi all!

I am a newbie in PHP and I have a question on using $_SESSION.

To keep it short, here is the code:

A.php:
<?php
if($_POST['username'] == 'USER' && $_POST['password'] == 'PWD'){
$_SESSION['isLogin'] = 1;
?>
<script language="javascript">
window.location.href="B.php";
</script>
<?php
}
?>

B.php:
<?php
print $_SESSION['isLogin'];
?>

Assume username and password is correct, but B.php show NOTHING!!!
That is, the $_SESSION haven't passed the value from one page to the
other page...

In php.ini: register_globals = On

My question is: how to pass the value from one page to another, without
using $_POST or some other things?

Thanks in advance.


You need to call session_start() at the top of both scripts.
Oct 4 '05 #2
al********@gmail.com wrote:
Hi all!

I am a newbie in PHP and I have a question on using $_SESSION.

To keep it short, here is the code:

A.php:
<?php
if($_POST['username'] == 'USER' && $_POST['password'] == 'PWD'){
$_SESSION['isLogin'] = 1;
?>
<script language="javascript">
window.location.href="B.php";
</script>
<?php
}
?>

B.php:
<?php
print $_SESSION['isLogin'];
?>

Assume username and password is correct, but B.php show NOTHING!!!
That is, the $_SESSION haven't passed the value from one page to the
other page...

In php.ini: register_globals = On

My question is: how to pass the value from one page to another, without
using $_POST or some other things?

Thanks in advance.


Also, in your code you are using the $_POST and $_SESSION arrays, which
is how you should access these variables with register_globals being
off. Why not turn it off and make your system more secure?
Oct 4 '05 #3
Thanks!

I change my php.ini in the following way:

session.auto_start = 1

And follow your comment:

register_globals = Off

Thanks for your support!!!

Oct 4 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Xizor | last post by:
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe. Let's say Joe and Bill are both using PHP with sessions on...
2
by: Jason Telisch | last post by:
I read and reread the PHP manual about sessions, and I have a quick question. What causes the session id to change? I tried destroying the session and unsetting the session vars, but it maintains...
1
by: Dave Cooke | last post by:
Hi, I have developed a website that uses Sessions to manage user state. It has come to my attention that the users that will be using this site do not want to enable cookies on their machines....
11
by: Stephanie Stowe | last post by:
Hi. I have an ASP page which stores a cookie. That cookie is then read on a different server. This is the crux of an ASP / JSP bridge I am creating for allowing a user to seemlessly switch from an...
7
by: Nikhil Patel | last post by:
Hi all, I am using a Session object in my ASP.Net application to store a value of a Database field. I can access it as ... int iProposalId = Session; The session timeout is set to 20. Now my...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
2
by: Dean R. Henderson | last post by:
For an ASP.NET web application, is there a way for one session (with appropriate security authorization) to set a HttpSessionState variable to point to another session and execute the Abandon...
1
by: Britt | last post by:
Hi, I read that SessionState is on by default. I also read that if it's not required, it must be better off (because of resources) My question is: i don't use session variables (like e.g....
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.