Solved

Can't retrieve Session Variables on second page

Posted on 2003-11-23
8
421 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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