Solved

Can't retrieve Session Variables on second page

Posted on 2003-11-23
8
426 Views
Last Modified: 2013-12-13
I'm registering some session variabels after successful login, but when i try to retrieve those session variables on second page, it gives me empty values.

However i tested session variables on same page of loginscript. It shows me the results, but no response on another page.

What's the solution??
0
Comment
Question by:akilwani
8 Comments
 
LVL 1

Expert Comment

by:show_source
ID: 9810398
You should show the code you are using, then it would be eaiser to help.

but this should work, if session.save_path is correct defined in php.ini

page1.php:

<?php
session_start();

$_SESSION["test"] = "Just a test";
echo $_SESSION["test"];
?>
<p>

<a href="page2.php">Page 2</a>

page2.php

<?php
session_start();

echo $_SESSION["test"];
?>
<p>

<a href="page1.php">Page 1</a>
0
 

Author Comment

by:akilwani
ID: 9813097
i've set the session.save_path to C:/Windows/Temp in php.ini. I checked the temp, its saving the session variables. But its strange that i can't retreive the session variables in inner pages.

Also I tested your simple script....I can't retrieve session variable on page2.....

0
 
LVL 4

Expert Comment

by:duerra
ID: 9839340
Greetings,
Make sure you are calling session_start() at the top of every page.  If it is not called on every single page that you are using PHP session variables, you will not have access to them.

Hope that helps
~duerra
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:akilwani
ID: 9841906
Actually the problem was in PHP.INI file...i extended the session time and now session variables are working fine.
0
 
LVL 4

Expert Comment

by:duerra
ID: 9842538
=)

Glad you figured it out.  You can get your points refunded from the Community Support area.  Just post this link in there and tell them that you found your answer.
0
 
LVL 4

Expert Comment

by:duerra
ID: 9844471
He found his answer.  No objections.
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 9862559
PAQed, with points refunded (50)

Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question