Solved

Session problems

Posted on 2004-08-12
3
268 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP populating an array. 4 23
php simple error message 4 22
Really simple no curl. Send a post 3 times 4 22
How can I make this form submit to itself? 10 25
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

813 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

14 Experts available now in Live!

Get 1:1 Help Now