Jump to content

session security stuff


jk11uk

Recommended Posts

my login page regenerates the session id then sets $_SESSION[user] = (the username logged in with)

 

this $_SESSION[user] is then used to get info on loads of different pages. would a hacker just easily be able to make a session and set their username to whatever they wanted? ofr is this seccure?

Link to comment
Share on other sites

Not really.

 

echo "$_SESSION[user]";

 

works, while

 

echo "$_SESSION['user']";

 

wouldn't.

 

I believe you that it somehow works in your application, but he's right about the syntax. If the key is anything other than a numerical index, the key String should be quoted as such. To echo in quotes without concatenating, or saving the session var into a simpler var like $user = $_SESSION['user'], then echoing, you can use this syntax (I forget the name):

 

echo "{$_SESSION['user']}";

 

works for all arrays such as:

 

echo "favorite browser is {$browsers['favorite']}, while the worst is {$browsers['worst']}";

Link to comment
Share on other sites

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.