Confused about sessions
Moderator: General Moderators
-
kral_majales
- Forum Commoner
- Posts: 36
- Joined: Wed Nov 24, 2004 2:47 pm
- Location: Dorset, UK
Confused about sessions
A while ago, I made a user login system for a site of mine. It was my first attempt at something like that in php, and not surprisingly, it didn't work properly!
I was using sessions for the users, and that's where I think the problems came from. When a user logged in, they logged in fine, then, when they went to another page, they were logged in as one of the other users! This was a really weird problem. I then switched over to using cookies instead, and it all worked perfectly (so it wasn't too much of a failure!).
I think part of the problem comes from my own confusion about sessions. This time round, I'd like to send the session id from one page to another using the SID value appended to the url. Once I've done that, how do I then access that session id on the next page that the user goes to and tell the script to use that session? Or is it done automatically?
any help would be greatly appreciated!
K
I was using sessions for the users, and that's where I think the problems came from. When a user logged in, they logged in fine, then, when they went to another page, they were logged in as one of the other users! This was a really weird problem. I then switched over to using cookies instead, and it all worked perfectly (so it wasn't too much of a failure!).
I think part of the problem comes from my own confusion about sessions. This time round, I'd like to send the session id from one page to another using the SID value appended to the url. Once I've done that, how do I then access that session id on the next page that the user goes to and tell the script to use that session? Or is it done automatically?
any help would be greatly appreciated!
K
Once you opend session you have it in the window.
so, when you go to another page, to check if session openned, you write:
so, when you go to another page, to check if session openned, you write:
Code: Select all
<?php
if (!isset($_SESSION["person_id"])){
header ("Location: /login.php");
exit;
}
?>-
kral_majales
- Forum Commoner
- Posts: 36
- Joined: Wed Nov 24, 2004 2:47 pm
- Location: Dorset, UK
just yesterday some asked a question similar to this.
it may be helpfull to you
http://codewalkers.com/forum/index.php? ... lm=default
it may be helpfull to you
http://codewalkers.com/forum/index.php? ... lm=default
Last edited by rehfeld on Wed Nov 24, 2004 3:29 pm, edited 1 time in total.
-
kral_majales
- Forum Commoner
- Posts: 36
- Joined: Wed Nov 24, 2004 2:47 pm
- Location: Dorset, UK
-
kral_majales
- Forum Commoner
- Posts: 36
- Joined: Wed Nov 24, 2004 2:47 pm
- Location: Dorset, UK
- MarK (CZ)
- Forum Contributor
- Posts: 239
- Joined: Tue Apr 13, 2004 12:51 am
- Location: Prague (CZ) / Vienna (A)
- Contact:
He wrote it just in the plane when he was leaving CZ after czech university students named him "King of majales" (if I remember well my literature classkral_majales wrote:no worries, I'm english though, sorry to say! i got the name from a poem i read years ago, by alan ginsberg i think...MarK (CZ) wrote:[absolutely off-topic]
2kral_majales: Aren't you czech? Determining by your nick..?
[/off-topic]
Sorry for off-topic post![]()
P
Ok, back on topic.
-
kral_majales
- Forum Commoner
- Posts: 36
- Joined: Wed Nov 24, 2004 2:47 pm
- Location: Dorset, UK
ah yeah, that's the one, i remember now! if i remember correctly, it's a pro-peace poem, which was perhaps one of the reasons i liked it. i'm gonna go upstairs and find the book it's in now, lol!MarK (CZ) wrote: He wrote it just in the plane when he was leaving CZ after czech university students named him "King of majales" (if I remember well my literature class). So I thought you could be czech
![]()
Ok, back on topic.
K