Hello,
I am using PHP 5, Apache on WinXP.
Here is the first php named 1.php
<?php
session_start() ;
$_SESSION[0] = 22 ;
echo $_SESSION[0];
?>
<a href="http://localhost/2.php"> 2php </a>
Here is second php named 2.php
<?php
session_start() ;
if (isset( $_SESSION[0]))
{echo 'set';}
else
{echo 'not set';}
?>
When I ran http://localhost/1.php, there was no problem at all. When I click on the link, 2.php gives 'not set'. Why is the session variable $_SESSION[0] not passed on for 1.php to 2.php? Please help.
3 2922
Hi,
Dont use 0 inside $_SESSION['']. I think '0' or '1' indicates true or false. This might be the problem. Instead of 0 I used the variable value inside session, now it is displaying the set.
This code works. - <?php
-
session_start();
-
$_SESSION["value"] = "Tested" ;
-
echo "Session value is ".$_SESSION["value"];
-
echo "<BR>";
-
?>
-
<a href="http://localhost/two.php"> Two.php</a>
-
-
-
<?php
-
session_start();
-
if (isset( $_SESSION["value"]))
-
{echo 'set';}
-
else
-
{echo 'not set';}
-
?>
Hi,
Thanks for you help. It still does not work on my system.
I looked into Cookies in the browser (I use Firefox). Under localhost, it shows localhost PHPSESSID. Session variable of $_SESSION["value"] isn't there. I thought all session variables are stored as cookies along with the session id until the session is destroied.
By the way, session variable is essentially an array. I believe the syntax of $_SESSION[0] is perfectly legitimate.
Thanks
Hi,
Thanks for you help. It still does not work on my system.
I looked into Cookies in the browser (I use Firefox). Under localhost, it shows localhost PHPSESSID. Session variable of $_SESSION["value"] isn't there. I thought all session variables are stored as cookies along with the session id until the session is destroied.
By the way, session variable is essentially an array. I believe the syntax of $_SESSION[0] is perfectly legitimate.
Thanks
You mentioned that session variables are stored as "cookies along with the session id", however, that is not true in your case. The method that you are using I believe would not store the variables in the cookie, rather it would store it in a session file on the server side. The cookie is just to tell the server, which session it should be looking for.
Here is an example.
[PHP]
<?php
session_start() ;
$_SESSION['one'] = 1;
$_SESSION['two'] = 2;
echo session_id();
?>
[/PHP]
now if I were to go to my C:/wamp/www/tmp/ [whatever my session id was] file
and open it in a text editor.
one|i:1;two|i:2 ;
The above is stored in that file. There is documentation on session on www.php.net .
Anyhow, I tried your code, and I also tried putting in numbers like $_SESSION[3] , $_SESSION[4] and so on. They all give the same effect. I'm not an expert, but I think the above post might be right about using numbers are your keys in a superglobal.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nick Whitelegg |
last post by:
Hello,
I'm having an odd problem with combining an authentication session
variable with header() redirection. Basically I have an authentication
script which checks a username/password. If the login is correct a
session variable containing the username is set and the user is
redirected to the (restricted access) main menu page.
The problem is, the FIRST (and only the first) time the user attempts
to login, the "Session variable not...
|
by: doltharz |
last post by:
Please Help me
i'm doing something i though was to be REALLY EASY but it drives me
crazy
The complete code is at the end of the email
(i mean newsgroup article),
i always use Option Explicit
and Response.Expires=-1,
|
by: Scott Wickham |
last post by:
I'm having a problem saving session information on one form and retrieving it
on a subsequent form...for only one out of a number of users. Actually, I'm
not absolutely certain it's a session problem but I'm hoping the experts can
help me figure that out.
Our application uses a session variable to "pass" info from one form to the
next. It has always worked fine for our users until a few weeks ago when one
of our users started having a...
|
by: farooqazeem |
last post by:
Hi guys,
I’m facing some problem can u solve it.
Problem is:
I’m giving user Id and password in (Login_sess.asp) and submit it to page
(sess_test.asp). I am setting session variable (session(“Sin”)=”Yes”) just
before redirecting to the same page, but in first time I do not received the
value of session variable when I redirect it, when I execute this process
second time or redirect it only with the page name...
|
by: Marc Rivait |
last post by:
Here is a very interesting scenario.
I have a simple test application that loads a page and sets a session
variable on the load event. On the first page there is a link to a second
page. The load event of the second page displays the value of the session
variable.
The problem is that when I use a W2k machine, this little test works
perfect. Session variable value is displayed on the second page. However,
when I use my XPPro...
| |
by: William LaMartin |
last post by:
I have a problem, mentioned here before, of Session and Application
variables disappearing at one site but not at others or on my development
computer.
The problem is illustrated by an example at
http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session,
Application and Cache variables on the first page and then on the second
page view them as the second page is refreshed every five seconds. Before
10 refreshes, the...
|
by: Greg Linwood |
last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost
embarrassing asking this as I've been using ASP since it was first released
& it really shouldn't be this hard to use - perhaps I'm just not very smart
or perhaps MS is making this too hard for us sql bunnies to understand - I
dunno, but I'd really appreciate someone explaining what I'm doing wrong
here & perhaps suggest a better approach..
I'm familiar with use of...
|
by: Werner |
last post by:
Hi Patrick!
Can you give an example of how to use a frameset inside an aspx-file?
When I create a new frameset in Visual Studio.Net it just gives me a htm-File.
Or give me a link where I can find one?
Thanks
Werner
P.S. Somehow I did not manage to do a followup in Googles newsgroups.
|
by: Lucas Tam |
last post by:
I'm calling the session object from an inherited page. The page is based
off an herited class which outputs XML.
Does anyone know why the session object would be nothing?
httpcontext.current.request/response/etc all work, except for session.
Thanks.
--
|
by: T Ralya |
last post by:
I am told that ASP.NET controls the session ID and session variables, but
that does not fit my symptoms. I am posting here as directed. I'm hoping
that someone can at least recommend something to try to isolate the problem.
I have a simple application that demonstrates my problem.
Page 1, step1: SaveSessionVariableButton will create a string value, show
it on screen, save it in a session variable and show the session ID on screen....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |