Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with session_register

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
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…
Suggested Courses

618 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