Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Sessions in frames

General discussions related to php

Moderators: macek, egami, gesf

Sessions in frames

Postby Xeth » Sat Jul 19, 2003 5:33 am

OK, once again I have a problem. :S

I am creating a member login area. This area has a login page which is out of frames, and the page the user receives once theyve logged in has a menu frame and a main frame.

How would I transfer the session ID into the frames pages?

Thanks in advance for any help you can offer.
User avatar
Xeth
New php-forum User
New php-forum User
 
Posts: 38
Joined: Tue Jul 08, 2003 10:59 am

Postby swirlee » Sat Jul 19, 2003 10:14 am

You don't need to do anything differently to use sessions in frames. If you're using the cookie method, it should work seamlessly. If you're using the GET method, just direct the browser to the page as usual: script.php?sid=0000 (where the 0000 is your sid, of course).
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Xeth » Sat Jul 19, 2003 10:44 am

yeah thats what I used in the end, but the problem with that is that its so messy, because when using links, there's an automatic addition of PHPSESSID on top of my own SID, so you get a very long URL, plus I have to write scripts for both PHPSESSID and SID which is twice the work and hard to follow.

Seems like the cookie method is the way to go, but I dont see what piece of code you add to use cookies instead of get. Do you just use: setcookie(sid,0000);?

It seems like I have found my true match; sessions. These are much more difficult to use then other functions in PHP whether you understand them or not! Damn sesssions.... GRR.
User avatar
Xeth
New php-forum User
New php-forum User
 
Posts: 38
Joined: Tue Jul 08, 2003 10:59 am

Postby swirlee » Sat Jul 19, 2003 10:51 am

Yes, you just use setcookie(), but your syntax isn't quite right. Check out the documentation.

Sessions are indeed a rather difficult thing to get going the first time around. What I recommend is that you find a good tutorial or two on the subject. This'll get you a better start than we could provide.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Joel » Sat Jul 19, 2003 4:21 pm

It seems everyone is still in 2002. PHP can now transfer session information transparently. No cookies, no ugly GET's. Although, read this from php.ini

http://www.php.net/manual/en/ref.session.php

Look for 'session.use_trans_sid boolean'

After looking in my php.ini and finding this turned off, yet I have pages, which use sessions and I do not store info in a cookie or GET, and no cookie is made automatically, yet it still works.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Postby Xeth » Sun Jul 20, 2003 3:34 am

Thanks alot for your help once again. Still not sure how the "transparent" thing works, and I cant use it with the web host I've been assigned anwyay. I think I'll stick to the cookies way of doing things for now. Twill prolly help me understand whats going on a bit better.

Just one last qstn on the subject; when I use set cookie, I can call the variable on another page ok, but no sign of the cookie in my Temporary Internet Files.

I'm about to start my second project: a hand-written message forum. Big project I'm guessing, so I'm hoping to get the sessions right otherwise I'll have to start over like with my admin area! lol. Thanks again for your help.
User avatar
Xeth
New php-forum User
New php-forum User
 
Posts: 38
Joined: Tue Jul 08, 2003 10:59 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.