Solved

Can't retrieve Session Variables on second page

Posted on 2003-11-23
8
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

623 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