Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can't retrieve Session Variables on second page

Posted on 2003-11-23
8
Medium Priority
?
442 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
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 …

704 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