Jump to content

[SOLVED] whats the best way to transfer variables between pages?


Recommended Posts

hi all.

 

im trying to figure out the best way to do this:

 

when my user enters his/her username and password into a form they are posted to the next page where they are assigned to $username and $password and then checked against the database (this all works).  now i want to use these two bits of data on vitrually ever subsiquent page... is there any way to carry them over to all the other pages other than making invisible forms to post them? (i allready have forms posting other data.)  if so could someone explain how i could do it.

 

thanks very much for reading

and thanks in advanced for any help you may be able to offer.

 

RMMO  ;D 

@TransmogriBenno: He should store the whole user data array that he gets from the query in the session so he doesn't need to requery again just to display say...the username or something.

 

I disagree.  If a session is hijacked, I'd rather only a single abstracted id be available to the hacker than all the info on a silver platter be just handed to them.

Unless you echo the password out, they can't do anything with the session.  The session being hijacked only means that the "hacker" can access things that the user could access, which is no less secure than just storing the session ID.

But if he utilizes some techniques such as changing session ID with http://php.net/session_regenerate_id will hijacking really be a major issue?

 

It makes it harder, but not impossible.

 

Unless you echo the password out, they can't do anything with the session.  The session being hijacked only means that the "hacker" can access things that the user could access, which is no less secure than just storing the session ID.

 

Okay well then how about packet sniffing?

But you're not transferring the password over TCP/IP, it's just stored in the session.  Hijacking sessions and actually robbing your server of the session files are two completely different things.  Unless you had a page like:

 

hackme.php

session_start();
echo serialize($_SESSION);
Password: $_SESSION['password'];

 

You should be fine.

@DarkWater

 

I agree re: storing additional data in the session, under 2 conditions:

1. The other data needs to be displayed somewhere (it might not, I build a lot of systems in which this is the case) - best to store as little data in the session as possible.

2. The session is updated as soon as the row is updated by the user, e.g. if there's an "update my details" form - stale data is ugly.

 

There is also an issue if the actions of admins or others affect the situation, e.g. if an admin bans or deletes a user, you need to check the database every time they view a page, otherwise they can stay on until their session times out.

great, that worked a treat!

 

interesting disccusion guys.. i think you came to an agreement at the end of it... both ideas are great depending on the needs of the system... ill just store the usrnm and paswd in this case as they are the only bits i need later on.

 

thanks to both of you!

 

my problem is answered! so this post is <SOLVED>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.