sessions question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

sessions question

Post by m3rajk »

how do i set my own variables and then access them?

is it simply:
session_register('variable');


and then to use it later, $new_variable=$_POST['variable'];

i also would like to know how to have them passed so that they won't show up in the url, without using forms on every page.. anyone have advice?
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Check out this thread:

viewtopic.php?t=6521
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

much better than the book and man pages. i might have been slightly off..

ok. what if i call a page with a function that's in a get variable, and i want to have sessions on in the background that control who it is.

i also want to prevent sessions from appearing in the page because i don't want people to see it and be able to adapt it to get privledges they shouldn't have, yet i want to keep it as userfirendly as possible.

i've notived that pages that get the little secure paage icon in ie and netscape can't have the back button used (at least all the ones i've seen) so i'd like to avoid not being able to use the back button.

does anyone have suggestions?
inn
Forum Newbie
Posts: 8
Joined: Fri Dec 13, 2002 1:21 pm
Location: Malé, Maldives

Post by inn »

you session thingy will work like this. in each page you want to enable session the best way is to start the session using session_start (); at the very beginning of the script. You can assign session vars using the superglobal array $_SESSION ie: by saying $_SESSION['myvariable'] = "myvalue"; or whatsoever.

in the proceding page you can initialize the session the same way as above and to use the variable that you require by some thing like say: echo $_SESSION['myvariable'];

thats it. about the browser back buttons you should look a bit into dhtml. i guess its controlled by javascript.
Post Reply