[wp-hackers] Using php Sessions

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Mar 30 00:33:14 UTC 2012


WordPress doesn't use PHP Sessions as it has no need for it (As it
doesn't have a "Session" state, only a logged in state)

There's no technical reason why you shouldn't use sessions if your
server environment supports it. Just ensure you call session_start()
before any headers are written.
Sessions are probably better for your usage, as you can write data to
it during the pageload, whereas, cookies can only be done before the
pageload starts.

On 30 March 2012 11:30, Matt Slocum <mattslocum at sharefaith.com> wrote:
> Hi,
> I'd like to keep track of some visitor's data while they browse my site and
> modify some navigation options based on their behaviors. I could do this
> using php's set_cookie() and store some info and make the desired
> modifications. Using cookies is somewhat iritating because I have to do my
> logic that I want included into the cookie before the headers are sent.
> I've done other PHP programming on non-wordpress sites and I normally use
> SESSIONS. I know that WordPress does not use sessions by default. It would
> be nice to use them since I could change some of the session data after the
> tracking cookie has been sent, and it would still persist because of the
> nature of sessions.
>
> Is there any reason that I shouldn't use php sessions on my site?
>
> Both styles would send another cookie. I guess non-session style would use
> fewer system resources. Is that the only reason?
>
> Thanks,
> Matt
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list