473,394 Members | 1,759 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,394 software developers and data experts.

retrieving data from session id??

Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
?>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Am I missing something?

Thanks
Ben

Aug 15 '06 #1
6 8784
You have to tell PageB to do something with the session created by
PageA. For example:

session_id ($_GET['sSID'])

but be shure to clean sSID before you use it like this ...

cr*********@yahoo.com wrote:
Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
?>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Am I missing something?

Thanks
Ben

--
--------------------------------------------
m2m server software gmbh - http://www.m2m.at
Aug 15 '06 #2
On 08/15/2006 01:10 AM, cr*********@yahoo.com wrote:
Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>
[...]
The parameter "sSID" is not the default PHP session id
parameter name, which is PHPSESSID. You might have
'session.name' in your configuration to 'sSID'; I don't know.

Under certain circumstances, PHP automatically sets the
PHPSESSID parameter for you. Read the docs to see if you can
get that to work.

(Follow ups set to alt.comp.lang.php)
Aug 15 '06 #3

<cr*********@yahoo.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
?>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Am I missing something?

Thanks
Ben
Try adding to all pages at the top in the php area:

session_start();

Shelly
Aug 15 '06 #4
hi,
before trying to retrieve values in $_SESSION , you have to call
session_start() , and php will fill the array of session.
A+

"m2m tech" <te**@m2m.ata écrit dans le message de news:
44***********************@newsreader01.highway.tel ekom.at...
You have to tell PageB to do something with the session created by PageA.
For example:

session_id ($_GET['sSID'])

but be shure to clean sSID before you use it like this ...

cr*********@yahoo.com wrote:
>Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
?>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Am I missing something? Thanks
Ben


--
--------------------------------------------
m2m server software gmbh - http://www.m2m.at

Aug 15 '06 #5
Rik
cr*********@yahoo.com wrote:
Hi all,

Please help me out here.

This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
>>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Am I missing something?
1. session_name() on EVERY page.
2. session_start() on EVERY page.
3. Don't use $sSID, use $_GET['sSid'];

Grtz,
--
Rik Wasmus
Aug 15 '06 #6
<cr*********@yahoo.compíse v diskusním príspevku
news:11**********************@75g2000cwc.googlegro ups.com...
Hi all,

Please help me out here.

Am I missing something?
Yes ;-) You must start session on each page where you want set or get
session infos and close it.

on Page A:
<?php
session_start(); // THIS IS IMPORTANT
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
session_write_close(); // THIS IS IMPORTANT TOO
?>">Docs</a>

on PageB:
<?php
session_start(); // THIS IS IMPORTANT
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
....
session_write_close(); // THIS IS IMPORTANT TOO
?>
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Aug 16 '06 #7

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

Similar topics

5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
3
by: Jakob Petersen | last post by:
Hi, I need to increase the speed when retrieving data from a hosted SQL Server into VBA. I'm using simple SELECT statements. How important is the speed of my Internet connection? (I have...
0
by: DC01 | last post by:
I have added a new measure successfully into the normal cube. I then add it to the virtual cube and reprocess all cubes. I can browse the normal cube successfully. Then when I try and browse the...
1
by: hanusoft | last post by:
This is an example of Inserting and Retrieving data from xml file. private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here ...
1
by: hanusoft | last post by:
This is an example of Inserting and Retrieving data from xml file. private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here ...
4
by: smartin | last post by:
Hi, I'm having problem retrieving data from an SQL stored procedure. I tried debugging but it wont give a the reason for the error. it just throws an exception after executing cmd.ExecuteNonQuery...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
10
vikas1111
by: vikas1111 | last post by:
Hi All Can anyone give me an idea to solve the problem.. My Problem is ,, I want to Retrieving data from database and displaying in textbox... If anybody have link of some good tutorial on...
7
by: splendid9 | last post by:
Problem in retrieving data from a XML file.......this is my code- protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.