Solved

Problem with session_register

Posted on 2003-10-27
3
519 Views
Last Modified: 2013-12-13
I creating session variable with this code :
<?php
  session_register("var_x");
  $var_x = "123456";

  print(" session_id() . "<BR>\n");
  print("Session variable is : $var_x");
?>

I get nothing when read that variable with this code :
<?php
  session_start();

  print("SID : " . session_id() . "<BR>\n");
  print("Session variabel is :   <BR>\n");
  print($var_x);
?>

SID is appear but print($var_x) doesn't print anything, What's wrong ?
Thanks.
0
Comment
Question by:shanyuen
[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
3 Comments
 
LVL 2

Expert Comment

by:errows
ID: 9629052
before registering your variable, start it as well.

<?php
  session_start();
  session_register("var_x");
  $_SESSION["var_x"] = "123456";
0
 
LVL 6

Accepted Solution

by:
DoppyNL earned 50 total points
ID: 9632090
You con't have to use session_register anymore! it may be removed from future versions of PHP so you're better of not using it anymore.

You can do it like this:

<?php
session_start(); // start the session
$_SESSION['myvariable'] = 123; // store "123" in "myvariable" in the session
?>

on each next page you can use $_SESSION['myvariable'] to use that variable (make sure you used session_start() first!)
0
 
LVL 5

Author Comment

by:shanyuen
ID: 9632364
I had fix it myself.
The problem is in php.ini
session.save path still "/tmp"
Then I change to my local drive.

Anyway, thanks for the information.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 …

749 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