Solved

Session problems

Posted on 2004-08-12
3
246 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
Comment Utility
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
Comment Utility
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
Comment Utility
quite alright :)

just make sure you use

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

to set sessions, session_register is no longer required

|)iablo
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now