Welcome, Guest. Please Login or Register.
May 09, 2025, 11:01:53 AM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  Sessions Mod « previous next »
Pages: [1] 2 Reply Ignore Print
Author Topic: Sessions Mod  (Read 537 times)
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Sessions Mod
« on: January 01, 2003, 10:16:19 PM »
Reply with quote

Replace the cookies with sessions.  Chris wrote this mod once before but he didn't make it so that you could stay logged in once you close your browser.
http://www.yabbse.org/community/index.php?board=158;action=display;threadid=10983
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #1 on: January 01, 2003, 10:33:09 PM »
Reply with quote

Doesn't 1.5 already use sessions? And you would need to use cookies anyhow to somehow know who the person was when they came back to the board after closing their browser wouldn't you?
Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #2 on: January 01, 2003, 10:34:22 PM »
Reply with quote

Quote from: Gobalopper on January 01, 2003, 10:33:09 PMDoesn't 1.5 already use sessions? And you would need to use cookies anyhow to somehow know who the person was when they came back to the board after closing their browser wouldn't you?
Yes but not for logins.  Sessions do use cookies to store a session id depending on how you do it.  I have played with it a bit but am confused, thus asking for someone to make the mod. :P
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #3 on: January 01, 2003, 10:41:50 PM »
Reply with quote

Well the session won't last on the server side once you close your browser as the server deletes them after a certain time period.
So everytime you come back you will have to start a new session anyhow and right now it uses the user/password cookies to do that. What other way would you want to do it?
Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #4 on: January 01, 2003, 10:49:02 PM »
Reply with quote

Sessions arn't actually destroyed on the server after the browser is closed.  Well, they are but the time it takes is somewhat random.  My basic idea behind this is currently if you log in and your browser does not accept cookies then you click once and you are logged out.

With sessions worst case is you login in and are logged out once you close your browser instead of having one click and being logged out.

Best case if you login and the cookie is set with the session id or something, this is where I got confused, so that when you visit the forum the next time after closing your browser you are still logged in.

I actually got all of that working.  My problem was setting the login length.  If I said login for 2 minutes, after two minutes I was still logged in.
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #5 on: January 02, 2003, 12:07:29 AM »
Reply with quote

Ah ok, so something like a backup method where you use $_SESSION to store the username/password in case cookies don't work?

How are you setting the length of the login?
Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #6 on: January 02, 2003, 12:11:29 AM »
Reply with quote

Quote from: Gobalopper on January 02, 2003, 12:07:29 AMHow are you setting the length of the login?
That was the issue, is the session_start() was making a cookie along side my cookie.  It was that cookie I couldn't seem to destroy.
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #7 on: January 02, 2003, 12:14:47 AM »
Reply with quote

I did some more looking I think that cookie always happens... You're talking about the one that stores the session ID right?

Maybe just rewrite that cookie to change the length of it?
« Last Edit: January 02, 2003, 12:19:44 AM by Gobalopper » Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #8 on: January 02, 2003, 12:18:49 AM »
Reply with quote

session_register just registers a session variable and it is better to use $_SESSION array anyway.
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #9 on: January 02, 2003, 12:22:09 AM »
Reply with quote

Yep I just realized that. You could try rewriting the session cookie though. Using something like this to set the liftetime.

$info = session_get_cookie_params();
setcookie(session_id(), '', $some_time, $info['path'], $info['domain'], $info['secure']);
Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #10 on: January 02, 2003, 12:23:05 AM »
Reply with quote

This is why I want someone to write this mod, I am just guessing how to make it work.
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #11 on: January 02, 2003, 12:38:31 AM »
Reply with quote

You said you had another cookie, other then the default session one. What were you storing in that?
Logged
David
Destroyer Dave
Global Moderator
YaBB God
*****
Posts: 5761


I'm not a llama!

WWW
Re:Sessions Mod
« Reply #12 on: January 02, 2003, 12:41:00 AM »
Reply with quote

This was one version of what I tried.

At the beginning of the script
$cookieusername = 'caps';
$sesscookiename = $cookieusername.'_sessid';
if(isset($_COOKIE[$sesscookiename]))
   session_id($_COOKIE[$sesscookiename]);
   
session_start();
ob_start();


Later I played with the get and set params.

Login part, $sesscookiename is globalized at the begining of this function
   $expire = time()+(60*$Cookie_Length);
   setCookie($sesscookiename,session_id(),$expire,'/');
   session_cache_expire($expire);
   $_SESSION['username'] = $username;
   $_SESSION['password'] = $password;

To check if someone is logged in I do this
if (isset($_SESSION[username])) {
   $username = $_SESSION[username];
   $password = $_SESSION[password];
}
else {
   $username = "Guest";
   $password = "";
}
Logged

Gobalopper
Mod Team
YaBB God
*****
Posts: 993


Cookie Monster

WWW
Re:Sessions Mod
« Reply #13 on: January 02, 2003, 12:43:23 AM »
Reply with quote

Well I am working on fixing the cookie problems right now so I will see about adding in session support too.

What you have their looks to be close to what it should be. I think all that would have to be done is add if statements that checked to see if the SESSION already had the username/password set either before or after it checked the regular cookie.
« Last Edit: January 02, 2003, 12:46:34 AM by Gobalopper » Logged
tdodnz
Sr. Member
****
Posts: 275


Asleep zzzzz (Snore Snore)

ICQ - 166370583cnd_nz@go.com WWW
Re:Sessions Mod
« Reply #14 on: January 02, 2003, 08:50:31 PM »
Reply with quote

Yesah sessions sound good, they are also alot more secure  ;D
Logged
Pages: [1] 2 Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  Sessions Mod « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.097 seconds with 20 queries.