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
Solved

Session problems

Posted on 2004-08-12
3
276 Views
Last Modified: 2006-11-17
I am developing an online store who's server is WebStar and uses PhpStar on it. On my own test system. I don't have any problem executing my scripts. But on their system, I can't seem to store session variables.

This page sets the session variables:
http://www.calvarycch.org/ebstore/session.php

This page retrieves them:
http://www.calvarycch.org/ebstore/session2.php

These pages I am using just to figure out why it isn't working, hence their simplicity.
The code I am using to set the variables is the following:

<?php
      session_start();
?>

<!----All the html header stuff etc--->

<?php
      session_register("product1");
      $product1 = "foobar";
      print "The product has been registered";
?>


The code I am using to retrieve is:

<?php
      session_start();
?>

<?php
      print "Your chosen products are:\n\n";
      print $_SESSION['product1'];
?>

Thanks in advance for your help!

-Kyle
0
Comment
Question by:remmuh
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 125 total points
ID: 11789297
first try replacing this code

<?php
     session_register("product1");
     $product1 = "foobar";
     print "The product has been registered";
?>

with

<?php
     $_SESSION['product1'] = "foobar";
     if (isset($_SESSION['product1'])) {
      print "The product has been registered";
     }
     else {
      print "The product has not been registered";
     }
?>
0
 
LVL 2

Author Comment

by:remmuh
ID: 11789305
BINGO! Thanks. I am still fairly new to PHP; I am actually a ColdFusion developer so I am still adapting to this new language (which I like a lot!).

Thanks for your help!
-Kyle
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11789314
quite alright :)

just make sure you use

$_SESSION['varname'] = "value";

to set sessions, session_register is no longer required

|)iablo
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

856 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