Jump to content

[SOLVED] PHP sessions variable


freeloader

Recommended Posts

@futurewii: Yeah, you're wrong.  But I won't kill you.

 

@freeloader:  You need session_start(); at the top of all the pages by the way, lol.  Anyway:

 

1) Only the user who started the session can see it, and their session ID is stored in a cookie.

2) It is stored, by default, as files on your server.  It's relatively streamlined though.

3) You could...Or you could make a $user array that's filled on each page based on their user ID stored in a session, or you could serialize a User object for sessions... >_>  But you could store user levels directly too. =P

Link to comment
Share on other sites

The way in which I do it, is upon sign up, each user is assigned a "session code", and so the $_SESSION['code'] = the users code . Then, when Info is needed, it is looked up against that (I have assigned the variable $id to that to make it easier)

 

That way, if you were to store the username eg as the session code, then if it were changed during the session, it would not change. This way it does. But you could just tell your user their code. Quite why they would need to know I don't quite know.

Link to comment
Share on other sites

The way in which I do it, is upon sign up, each user is assigned a "session code", and so the $_SESSION['code'] = the users code . Then, when Info is needed, it is looked up against that (I have assigned the variable $id to that to make it easier)

 

That way, if you were to store the username eg as the session code, then if it were changed during the session, it would not change. This way it does. But you could just tell your user their code. Quite why they would need to know I don't quite know.

 

That didn't make an ounce of sense to me, sorry.  Why in the hell would you assign them a unique session "code" when you can just check against their userid?  Saves database space and is just simpler.

Link to comment
Share on other sites

Well you could, (I get mixed up here with other thingys...)

 

You see, I have sort of grouped rows....its difficult to explain So I won't. Ill just leave it at the "code" and an "id" are both needed for my table. But for you, yeah just use the ID thats what I meant.

Link to comment
Share on other sites

Well you could, (I get mixed up here with other thingys...)

 

You see, I have sort of grouped rows....its difficult to explain So I won't. Ill just leave it at the "code" and an "id" are both needed for my table. But for you, yeah just use the ID thats what I meant.

 

In that case, you should read up on database normalization and fix it so there's not "sort of grouped rows". =P

Link to comment
Share on other sites

@freeloader

 

i just dont want to get too far away so ill go back to your concern.

 

Session is on the server-side so you do not need to worry bout the information if it would be seen, unless, its accessed from the server itself (but too seldom do this since not all has access over the server :D).

 

if you really are that concern about security, encrypt all info in your session, store the session and all sorts of comparison... blah3x

 

to start a session (and to use one), you need session_start()...

to erase a session, you need session_destroy().

Link to comment
Share on other sites

@darkwater;

 

its not as simple as that. I have like a users thingy, where its running over multiple servers, where users need to be logged in, whilst assuming many users at the same time...just shush, trust me, I think I know a little about php to know what Im doing no offence :P

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.