Solved

Session problems

Posted on 2004-08-12
3
282 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
[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
  • 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
if (is_singular not working 5 39
restriction of entering a a page 5 34
assigning javascript variable to php variable 8 43
How do I post more than 1 item to php backend 24 32
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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
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.

726 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