Newbie Question-Sessions...can't get the to work
Moderator: General Moderators
-
matthiasone
- Forum Contributor
- Posts: 117
- Joined: Mon Jul 22, 2002 12:14 pm
- Location: Texas, USA
- Contact:
Newbie Question-Sessions...can't get the to work
I am tring to run sessions on a set of forms and admin pages on my website. I guess I am confused about where you need to start and restart sessions. I start and register a variable on the main page then when I goto the other page and start the sesion again that variable is not available.
Help
Matt
Help
Matt
Since you're not printing any code I'll write the code that is right. Check if you've done this:
You're second script:
Remember: It could be your server that is not set right
In you're second script you have to remember to use the session_start() since that have to be in every script that are going to use the session you created.session_start(); //In top of every document you will use session
session_register("my_var"); //The name of your variabel.
$my_var = "Hello"; //Sets the variable to Hello
You're second script:
You can also use $HTTP_SESSION_VARS['my_var'] to get the variable.session_start();
echo $my_var
Remember: It could be your server that is not set right
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Which ever method you use you will need to put session_start() at the top of each page in which you set or use a session variable. Have a look at http://www.php.net/manual/sv/ref.session.php as well.
Mac
Mac
-
matthiasone
- Forum Contributor
- Posts: 117
- Joined: Mon Jul 22, 2002 12:14 pm
- Location: Texas, USA
- Contact:
ok thanks for the suggestions,but the variables still aren't passing
the is the code where the session variables is set
And here is the it variables is asked for
Anymore ideas?
Matt
the is the code where the session variables is set
Code: Select all
<?
require_once("spall_fns.php");
session_start();
$_SESSIONї'var'] = $user;
do_pages($area, $page, $view, $id, $eid, $HTTP_POST_VARS, $mode, $cust);
?>Code: Select all
session_start();
echo "u= ".$$_SESSIONї'user'];
...Matt
matthiasone wrote: And here is the it variables is asked for
Anymore ideas?Code: Select all
session_start(); echo "u= ".$$_SESSIONї'user']; ...
Code: Select all
<?php
session_start();
echo "u=" . $_SESSIONї'user'];
?>-
matthiasone
- Forum Contributor
- Posts: 117
- Joined: Mon Jul 22, 2002 12:14 pm
- Location: Texas, USA
- Contact:
Which version of PHP are you using?
Also, within the configure script used to configure your install in PHP, do you see the following:
--disable-session
In your php.ini file (if you are using one, phpinfo() will tell you where PHP is looking for one) does PHP have proper access to write to the location specified in 'session.save_path' (defaults to /tmp, windows defaults to c:/temp I believe - but I know very little when it comes Windows).
Code: Select all
<?php
phpinfo();
?>--disable-session
In your php.ini file (if you are using one, phpinfo() will tell you where PHP is looking for one) does PHP have proper access to write to the location specified in 'session.save_path' (defaults to /tmp, windows defaults to c:/temp I believe - but I know very little when it comes Windows).
-
matthiasone
- Forum Contributor
- Posts: 117
- Joined: Mon Jul 22, 2002 12:14 pm
- Location: Texas, USA
- Contact:
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
On your second page you can also quickly see everything (if anything) in the $_SESSION array by doing:
On a side note, since you are using PHP 4.1 you can use $_POST instead of $HTTP_POST_VARS.
Mac
Code: Select all
echo '<pre>';
print_r($_SESSION);
echo '</pre>';Mac
-
matthiasone
- Forum Contributor
- Posts: 117
- Joined: Mon Jul 22, 2002 12:14 pm
- Location: Texas, USA
- Contact: