?
Solved

Problem with session_register

Posted on 2003-10-27
3
Medium Priority
?
527 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 150 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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

777 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