Jump to content

Sessions, keeping a session alive (Iam a new boy on the block)


gingerboy101

Recommended Posts

Hi guys,

Ok i have just started to write in PHP, I need a language that could talk to a data base that I could use e.g. mysql and php.

Anyway, I have been adding to the old favorite of everyones, the 'member login system', I have managed to get all of the basics working, and able to allow a login, called some variables back to show how was logged in, I want to be able to allow them to update their registartion, which is on a new page called 'update_reg.php' called from a simple html <a href=".......">update</a>.

But when I call the '$username' on the page 'update_reg.php' it is returned blank as are any other variables that I try, I have ensured the session_start(); is on the first (very first) line of the new page but it is not carrying the variables across.

I have looked in every forum I can find and tutorial, I am sure that I just being thick but, any help please.

If you nee to see any of the code then please shout.

p.s. php.ini global_variables = off.

Happy to learn so just point me anywhere that could help with this.

Cheers
Session variables (that can be accessed after calling session_start()) are stored in the $_SESSION array. That means if you want to pass the username from page to page using the session variables, you need to store it in the array- for an example $_SESSION['user'].


So, if page1.php is:
[code]<?php
session_start();
$_SESSION['something']="Test123";
?>[/code]

And page2.php is:
[code]<?php
session_start();
echo $_SESSION['something'];
?>[/code]

The output on page2.php will be "Test123".


Hope it helps,
Orio.
  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.