Session Management in Joomla!

Well, at least it’s 1st time i wrote on joomla! a framework based PHP that very2 prety in structure and have a lot of functionality.
Some of you maybe a joomla! developer and try to get a joomla session and put in another php file.
You can’t just put session_start() and get $_SESSION[] data. Joomla’s default session is saved on #__session table. so you need to reset back session save handler to file (or another , as we know, default session save handler in PHP is file mean session data is saved in file). Just put this code on joomla’s Component/module/plugin than session need to exported

$temp_session = $_SESSION; // backup all session data
session_write_close();
ini_set(“session.save_handler”,”files”); // set session saved hadler on file
session_start();
$_SESSION[“user”]= “I’m user”; // data that another php file need to know
session_write_close();
ini_set(“session.save_handler”,”user”); // put back session saved handler on database
$jd = new JSessionStorageDatabase();
$jd->register(); // set required parameters
session_start(); // restart //
$_SESSION = $temp_session; // restore last session data

of course you need to get session id that another php file must know. You can save it on cookie or pass it as parameter on new php file.

$e = session_id();
setcookie(“jsid”, $e, time()+3600,’/’);

nah .. in another php file you just need to set session_id and can start session
if($_COOKIE[“jsid”]!=””){
session_id($_COOKIE[“jsid”]);
}
session_start();
var_dump($_SESSION[“user”]);
so you can see new session displayed there. Of course it just display session in files and session that saved in database can’t be shown

39 comments so far

  1. riza on

    opo iki wa

  2. pribadidewa on

    ada deh🙂..

  3. Nur Aini Rakhmawati on

    sleeping session now🙂

  4. pribadidewa on

    waduh, suatu kehormatan besar nih , suhu joomla! kelas dunia mau komentar disini .. bikin ngantuk ya mbak artikelku😀.. ntar insya Allah nanti nulis yang lebih bagus lagi

  5. Irfander on

    Mas tolonglah aku yang desperate ini🙂.

    Saya pake login joomla trus di redirect ke sebuah halaman tersendiri. kalo redirectnya bisa, tapi gimana ngambil variabel session sehingga data user yang barusan login itu terbaca di halaman tersendiri.

    Mohon panduannya, terima kasih

    coba ikuti management session seperti di atas .. insya Allah bisa koq.. untuk mengetahui data user mana yang disimpan , coba pake perintah var_dump($_SESSION)

  6. demiss on

    That’s a good one. i’m also trying to use session variable in joomla frame work but your idea is a bit wider than i antisipated. do you know simpler methode to pass session variable from one file to other?

    i think this is the minimum requirement needed. isn’t it easy ?. the ONLY WAY we can do is change joomla! way to save session then put it back ..

  7. foil on

    bisa minta tolong dijelasin dlm bhs indo?

    trus yg bagian ini maksudnya ditaruh dimana ya:
    of course you need to get session id that another php file must know. You can save it on cookie or pass it as parameter on new php file.
    $e = session_id();
    setcookie(”jsid”, $e, time()+3600,’/’);

    bisa minta tolong gak misalnya pingin ngambil session username dari joomla trus username itu akan dipakai di php diluar joomla? script2 diatas diletakkan dimana aja ya?
    thanks bantuannya

  8. Wlad on

    friend, in which file should I put the code?

  9. Sam on

    where would i have to paste this code in order to get session details!

  10. Brat on

    Thank you for the great tip! After some fiddling, and more reading, I finally got this to work.

    I’ve seen several solutions that involve accessing Joomla mainframe within an external script. HOWEVER there are scripts that bomb if you try this (such as the standalone script I’m currently bridging to Joomla).

    First, you MUST have Session Handling set to Database (see your Joomla Global Configuration). This is usually the default upon installation, unless you changed it at some point.

    Just as the instructions above show, you have to put the sesssion creation code in your Joomla plugin or component (or a file that your plugin or component includes, in my case).

    THEN, you put the code that calls the session in your external script (the one that needs to get the data).

    What ISN’T well documented (I had to dig for it) is that, for this to work, each and every page of your script must call the session this way. You should have a central file (such as a header.php for example) that is called every time a page is rendered. THAT is where the session call goes.

    EXAMPLE:

    Joomla myPlugin -> create session
    My Script’s header.php file -> calls the session

    Now, every page in my script calls the header.php file, so every page in my script calls the session correctly. Keep this in mind when, say, you’re updating existing session variables – you gotta make sure you call that session correctly.

  11. hendar on

    mas … saya bingung dengan artikel nya , bisa tidak dijelaskan step by step disertai contoh langsung🙂 … harap maklum newbie …. thnks b 4

  12. honza22 on

    Thank you, you saved me another 2 hours!

  13. how do you get pregnant fast on

    Nice post. I learn some factor tougher on distinct blogs everyday. Most commonly it is stimulating to find out to read content by other writers and exercise a specific thing there. I’d would rather use some together with the content in my weblog no matter whether you don’t mind. Natually I’ll provide you that has a link in your net weblog. Many thanks for expressing.

  14. Hosting Gratis on

    Thanks atas tulisan menarik ini. Saya sendiri masih bereksperimen menemukan aplikasi content management yang paling cocok untuk digunakan sebuah situs berkonsep situs berita komunitas. Info ini sangat menarik untuk dipraktekkan🙂

  15. PHP Free Hosting on

    ini merupakan aplikasi yang cukup perlu untuk didalami lebih mendalam.
    Terimakasih atas sharing dan tulisannya. Semoga Sang Hyang Widhi memberkahi niat baik kisanak

  16. malesadvice.weebly.com on

    Hello just wanted to give you a brief heads up and let
    you know a few of the images aren’t loading properly. I’m not
    sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.

  17. mouse mats on

    whoah this weblog is wonderful i really like reading your posts.
    Keep up the good work! You realize, many individuals are searching around for this info,
    you could aid them greatly.

  18. www.sbwire.com on

    The first and most important step is to buy rid of every one of the unhealthy food out of your home and vow that it is not allowed back in.
    It will promote weight-loss when the users are
    learning new solutions to eat also to exercise. Again, taking careful note and drinking in moderation will
    be the key – Moderation AGAIN: Yep, I think we must
    beat this drum a little more, to comprehend that white wine can stall fat
    loss if not consumed moderately.

  19. children eating healthy on

    Please let me know if you’re looking for a writer for your weblog. You have some really great posts and I believe I would be a good asset. If you ever want to take some of the load off, I’d love to write some
    articles for your blog in exchange for a link back to mine.
    Please send me an email if interested. Kudos!

  20. seo-leeds.info on

    We are a group of volunteers and opening a new scheme
    in our community. Your website provided us with valuable information to work on.
    You’ve done a formidable job and our whole community will be thankful to you.

  21. what is vitamin c used for on

    I was suggested this website by my cousin. I am now not sure whether or not this put up is written by
    means of him as no one else recognize such targeted approximately my problem.

    You’re wonderful! Thanks!

  22. Doris on

    I was suggested this website by means of my cousin. I am no longer positive whether this put up is written
    through him as nobody else recognise such special approximately my trouble.
    You are incredible! Thanks!

  23. Colorado Kayak Coupon Code on

    I am now not positive the place you’re getting your info, however good topic. I must spend some time studying more or working out more. Thank you for excellent information I used to be looking for this information for my mission.

  24. Hello there, just became aware of your blog through Google, and found that it’s truly informative. I am going to watch out for brussels. I’ll appreciate if you continue
    this in future. Numerous people will be benefited from
    your writing. Cheers!

  25. www.facebook.com on

    My developer is trying to persuade me to move to .
    net from PHP. I have always disliked the idea because of the costs.

    But he’s tryiong none the less. I’ve been using Movable-type
    on a variety of websites for about a year and am concerned about switching to another platform.

    I have heard excellent things about blogengine.net. Is there a way I can transfer all my wordpress
    posts into it? Any help would be really appreciated!

  26. James on

    Just desire to say your article is as astounding.
    The clearness in your post is simply cool and i can assume you are an expert
    on this subject. Well with your permission let me to grab
    your RSS feed to keep up to date with forthcoming post.
    Thanks a million and please carry on the gratifying work.

  27. Robbie on

    Quality articles or reviews is the main to be a focus for the viewers to pay a quick
    visit the web page, that’s what this site is providing.

  28. www.slideshare.net on

    Hi just wanted to give you a quick heads up and let
    you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both show the same results.

  29. Lewis on

    I have been browsing online more than 2 hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you
    did, the internet will be much more useful than ever before.

  30. Eric on

    I was extremely pleased to find this web site. I want to to thank you for your time due to this fantastic read!

    ! I definitely appreciated every part of it and i also have you
    book-marked to check out new stuff in your web site.

  31. www.fajomagazine.com on

    Excellent blog here! Also your website loads up fast!
    What web host are you using? Can I get your affiliate link to your
    host? I wish my website loaded up as fast as yours lol

  32. Alfred on

    Great items from you, man. I’ve take note your stuff previous to and you’re just too excellent.
    I actually like what you’ve got here, really like what you’re saying
    and the way by which you are saying it. You are making it entertaining and you still take
    care of to keep it wise. I can not wait to learn much more
    from you. This is actually a terrific web site.

  33. best dentist on

    Hi there friends, how is everything, and what you want to say
    about this article, in my view its actually amazing in support of me.

  34. purchase seo zen on

    Definitely consider that which you said. Your favorite justification appeared to be on the web
    the easiest thing to remember of. I say to
    you, I definitely get annoyed at the same time as other people think about issues that they just do not realize about.
    You controlled to hit the nail upon the top and also defined out
    the whole thing without having side-effects , other people could take a
    signal. Will probably be again to get more. Thanks

  35. hen arks on

    Hi there Dear, are you truly visiting this website daily, if so
    after that you will without doubt get nice know-how.

  36. Way cool! Some very valid points! I appreciate you writing this write-up plus the
    rest of the website is also really good.

  37. It’s going to be end of mine day, however before finish I am reading this impressive piece
    of writing to improve my know-how.

  38. hack fb on

    Hi I am so glad I found your web site, I really found you by accident,
    while I was researching on Askjeeve for something else, Regardless I am here now and
    would just like to say cheers for a remarkable
    post and a all round enjoyable blog (I also love the theme/design), I don’t have time
    to read through it all at the moment but I have book-marked it and also added your
    RSS feeds, so when I have time I will be back to read more, Please do
    keep up the excellent job.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: