473,327 Members | 2,007 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,327 software developers and data experts.

Session not holding a value

Hello all,

I'm not familiar with PHP session, my question is if session save the values when I brows to another page.
It is possible to keep the session values when I go to other page (in the same domain)?

In one script, let's say a.php I'm doing:
[PHP]
session_start();
$_SESSION['fname'] = $row["fname"];
$_SESSION['lname'] = $row["lname"];
header("LOCATION: b.php")
[/PHP]

In b.php I'm doing:
[PHP]
print My name is: " .$_SESSION['fname']. " " . $_SESSION['lname'];
[/PHP]

I don't see the content of [PHP]$_SESSION['fname'] [/PHP] and [PHP]$_SESSION['lname'][/PHP]

Thank you,
Mar 16 '08 #1
8 4233
Markus
6,050 Expert 4TB
on b.php you need to initialise the session.

On any page that uses sessions you need to use
[php]
session_start();
[/php]
Right before any other code.

Regards.
Mar 16 '08 #2
Steel, I don't see the the session values...

what I missing??
Mar 16 '08 #3
Markus
6,050 Expert 4TB
Steel, I don't see the the session values...

what I missing??
Well i dont know what your code is on b.php so i dont know.
Mar 16 '08 #4
Lets say:

a.php contains:
[PHP]
<?php
session_start();
$_SESSION['username'] = 'shlomi';
$_SESSION['password'] = 'elbaz';
header("LOCATION: b.php");
?>
[/PHP]

b.php contains:
[PHP]
<?php
session_start();
print $_SESSION['username']. " " .$_SESSION['password'];
?>
[/PHP]

In the addressbar I see http://localhost/b.php but its show nothing
Mar 19 '08 #5
ronverdonk
4,258 Expert 4TB
You must have made another error or typo because, when running your 2 scripts unchanged on my localhost, it runs fine, i.e. both values are printed.

Ronald
Mar 19 '08 #6
Markus
6,050 Expert 4TB
You must have made another error or typo because, when running your 2 scripts unchanged on my localhost, it runs fine, i.e. both values are printed.

Ronald
As does mine.

Regards.
Mar 19 '08 #7
satas
82
Lets say:

a.php contains:
[PHP]
<?php
session_start();
$_SESSION['username'] = 'shlomi';
$_SESSION['password'] = 'elbaz';
header("LOCATION: b.php");
?>
[/PHP]

b.php contains:
[PHP]
<?php
session_start();
print $_SESSION['username']. " " .$_SESSION['password'];
?>
[/PHP]

In the addressbar I see http://localhost/b.php but its show nothing
Check session_save_path in your php.ini file. Make sure it has real path with write permissions.
Mar 19 '08 #8
Check session_save_path in your php.ini file. Make sure it has real path with write permissions.
Also you can do a printout of phpinfo() and make sure session support is actually enabled. It'd be odd but it could happen.
Mar 19 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Patrick | last post by:
Hello I'm running two Webservers Using ASP.NET. both are running the same ASP.NET Application, with <sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424"...
4
by: | last post by:
I'm not sure what to think of this. In the appliacation, upon postback, users screens will get mixed up. Meaning... Perhaps on my screen im working with a particular set of data. I click a button...
5
by: news.microsoft.com | last post by:
Hi everyone, I need some help (may be in the form of some sample code) for the subject question. I have an ASP.NET/C# application. I need to do quite a few tasks when the session ends. I...
2
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and...
0
by: josemario.hernandez | last post by:
Hi, I'm having a issue trying to change the value of a session variable. It seems like I just can set my session variable one time in the sessión. For example if I write: Session("Variable") =...
5
by: Steven Blair | last post by:
I have the following code: Session = new CurrentUser("TEST"); When I postback to the server, the Session is null. My guess is a only the refence to my actual class is stored, rather than the...
9
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would...
4
by: Jack Black | last post by:
Hi, all! Developed a basic ASP web site with MS Access 2k3 as a database back end. I've developed it on two different Win2k3 servers, and app works flawlessly on both. However, we just moved it...
3
by: rn5a | last post by:
A ASPX Form has a TextBox & a Button. Users enter their username in the TextBox & submit the Form after which records pertaining to the username get retrieved from a MS-Access database table &...
1
by: =?Utf-8?B?QXZp?= | last post by:
Hi I have an interesting issue, I hope someone can shead light on: I have a 2 server "web farm" with a web app that produces image files. To ensure synchronization of content on both machines,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.